1

I have a legacy Erlang program that needs optimizations. This piece of code uses up to 20G memory in run time. I'm wondering if there is a way to get the Erlang Beam size of the process itself in run time? If that is possible then I can do something like if beam size>10GB then reject all calls to gen_server process. Thanks for the help!

Jian Wang
  • 11
  • 1

2 Answers2

0

Perhaps you could use some proces_info data:

{memory, Size}: Size is the size in bytes of the process. This includes call stack, heap and internal structures.

process_info(self(), memory).   
{memory,17128}
0

Just start with calling memory() from the shell to learn if it is in binaries, ets, processes and so on the memory is being kept. Next you can ask a tool like etop to give you the processes using the most memory if a process is the culprit. This can often track down the problem.

If the problem is ETS or binaries, then you may be keeping certain large binaries around for a long time due to sub-binary pointers inside them. This needs GC tweaks to fix.

I GIVE CRAP ANSWERS
  • 18,739
  • 3
  • 42
  • 47