I have a 'worker' process which I am going to assign to a job. Before I spawn hundreds of processes of this type I would like to know the memory consumption figures for it.
I know that I should sum all the elements which are stored in the process' loop data (all tuples, atoms, lists, etc) and the actual process memory footprint.
As I understand, before doing that I have to know the actual size of a {tuple|atom|list|process} itself.
Given a certain data structure which is stored in the process' memory how can I calculate the overall size of the process in memory?
erlang:process_info/2
will give you the amount of memory, in bytes, that a process occupies. For example:
1> erlang:process_info(whereis(code_server), memory).
{memory,284208}
Note that binaries are not included since they are not located in the process heap. Those you have to count the size of manually.
Did you read the Erlang Efficiency Guide on Memory?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With