[erlang-questions] In-process memory sharing doesn’t seem to work

Krzysztof Jurewicz krzysztof.jurewicz@REDACTED
Tue Jun 19 21:16:51 CEST 2018


> You're running your tests in the shell which has sometimes slightly different characteristics from the compiled code. The shell runs an interpreter that has various performance overheards and additional data copying might be one of them. I'd suggest running the same tests from a regular, compiled module in a regular process (not the shell process) and comparing the results.

Thank you, it seems that this is indeed the case. Have added the following function to the hog module:

create_and_hold_tree(N, Watcher) ->
    T = tree(N),
    Watcher ! ok,
    receive
        {release, To} ->
            To ! T
    end.

1> memory(processes_used) / 1024 / 1024.
4.1407012939453125
2> Holder = spawn(hog, create_and_hold_tree, [25, self()]).
<0.79.0>
3> flush().
Shell got ok
ok
4> memory(processes_used) / 1024 / 1024.
4.1668548583984375
5> Holder ! {release, self()}.
{release,<0.76.0>}
6> memory(processes_used) / 1024 / 1024.
2692.868850708008



More information about the erlang-questions mailing list