top | item 13411912

(no title)

stormpat | 9 years ago

{_, mem} = :erlang.process_info(spawn(fn -> 1 + 1 end), :memory)

mem -> 2720 bytes (~2.7kb)

discuss

order

strmpnk|9 years ago

Which is pretty close to 338 words on a 64bit system (338*8). Looks like it's taking 2 extra words there though. Curious.

masklinn|9 years ago

    Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
    Eshell V8.1  (abort with ^G)
    > {memory, Mem} = erlang:process_info(spawn(fun () -> 1 + 1 end), memory).
    {memory,2704}
    > Mem div erlang:system_info(wordsize).
    338
338 words is what the "Advanced: Memory" guide lists: http://erlang.org/doc/efficiency_guide/advanced.html

> Erlang process 338 words when spawned, including a heap of 233 words.

However note that this is with HiPE and SMP enabled (which afaik are now the default) as the "processes" guide notes[0] without both of these a process should be 309 words. Without SMP, I get 320 words (HiPE is a compilation flag and I don't feel like recompiling Erlang right now).

[0] http://erlang.org/doc/efficiency_guide/processes.html