Processes memory

Marcel Meyer marcel.meyer@REDACTED
Fri May 7 15:00:41 CEST 2010


Hi there,
I have been playing around with the infamous "perms" example where all
permutations of a word is computed using this code:

perms([]) -> [[]];
perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])].

Before I run a calculation, I get the memory dump for the shell:
2> memory().
[{total,4309984},
 {processes,414604},
 {processes_used,408188},
 {system,3895380},
 {atom,292069},
 {atom_used,260714},
 {binary,324936},
 {code,1846671},
 {ets,129732}]

Then I run it:
3> test:perms("processese").

The issue is that I can only run this command once, after which a crash dump
is produced, talking about memory allocation that fails.
If I do a memory dump of the shell after executing the command once, this is
what I get:
4> memory().
[{total,867872760},
 {processes,864249884},
 {processes_used,864243468},
 {system,3622876},
 {atom,298605},
 {atom_used,268388},
 {binary,24192},
 {code,1867490},
 {ets,130684}]

The "processes*" have increased significantly.
I did not bind the result of that computation, so why is it still consuming
resources?

A side note: I posted the perms problem to all our developers in the office
(a .Net shop), and the fastest version (F#) was still twice as slow as the
code above.

Thank you in advance.
Marcel


More information about the erlang-questions mailing list