I came across this article about memory bloat in ruby. https://www.joyfulbikeshedding.com/blog/2019-03-14-what-causes-ruby-memory-bloat.html
I was wondering, does Erlang have the same problem and it is less noticeable or does Erlang avoid this somehow?
EDIT: Adding a bit of summary of the article because it’s rather long.
Ruby memory bloat has historically been claimed to be due to memory fragmentation. There is free space available, but the objects that need to be allocated won’t fit in any of those slots, so more memory is allocated for them. So, suggestions have been to use a smarter allocator, like
jemalloc or to set
MALLOC_ARENA_MAX=2 (default is 8 times the number of virtual CPUs).
The author noticed through experimentation that memory fragmentation wasn’t the problem. Instead, the problem seemed related to having multiple concurrent allocators. So, each allocator, would attempt to not step on each others toes by using its own distinct space. The
MALLOC_ARENA_MAX=2 addresses this by ensuring there are less concurrent allocators. However, the author found another way to use less memory, by having the ruby vm return the memory to the OS by calling