What causes Ruby memory bloat?
The author never made clear if they are measuring <i>virtual</i> memory usage, or <i>physical</i> memory usage. Having a lot of virtual memory does not &quot;cost&quot; much: it&#x27;s just having permission to use a lot of memory if you so wish. It&#x27;s possible to have huge chunks of your virtual address space with no physical memory backing them. Physical memory is the amount of physical RAM your process is using.<p>Memory managers tend to greedily request a lot of virtual memory because there&#x27;s usually little harm in doing so, and the act of asking the kernel for more permission (read: more virtual memory) is slow.<p>Minor quibble: it&#x27;s not accurate to call `malloc()` and family in glibc the &quot;operating system&#x27;s memory allocator.&quot; That is the memory allocator for C, and Ruby just so happens to be implemented in C. The glibc allocator will use the system calls `brk()`, `sbrk()` and&#x2F;or `mmap()` to request memory from the kernel (<a href="http:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;brk.2.html;" rel="nofollow">http:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;brk.2.html;</a> <a href="http:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;mmap.2.html" rel="nofollow">http:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;mmap.2.html</a>). Nothing really changes per the punchline.