Memory Usage

Erickson, John john.erickson@REDACTED
Tue Sep 29 18:11:57 CEST 2009


Hi, I am trying to store a large list of items and am a little surprised how much memory erlang is using.  As a test, I tried creating a list of 10M integers and measuring memory usage.  It takes around 600M.  If I convert this list to a binary using term_to_binary, it is only about 50M, which is more like what I would expect.  So I am wondering why there is 10x memory usage in the usual form?  One other small oddity, it seems after calling garbage_collect I am using more memory.

John

plxc7436> erl
erl
Eshell V5.7.2  (abort with ^G)
1> memory().
memory().
[{total,6841320},
 {processes,678056},
 {processes_used,664224},
 {system,6163264},
 {atom,397393},
 {atom_used,395331},
 {binary,14192},
 {code,3517670},
 {ets,249376}]
2> L=lists:seq(1,10000000).
L=lists:seq(1,10000000).
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,
 23,24,25,26,27,28,29|...]
3> memory().
memory().
[{total,611799440},
 {processes,605491288},
 {processes_used,605477456},
 {system,6308152},
 {atom,444017},
 {atom_used,410654},
 {binary,22912},
 {code,3604955},
 {ets,251952}]
4> garbage_collect().
garbage_collect().
true
5> memory().
memory().
[{total,950170384},
 {processes,943869400},
 {processes_used,943855568},
 {system,6300984},
 {atom,444017},
 {atom_used,410654},
 {binary,15744},
 {code,3604955},
 {ets,251952}]
6> size(term_to_binary(lists:seq(1,10000000))).
size(term_to_binary(lists:seq(1,10000000))).
49999242
7>


More information about the erlang-questions mailing list