From: Yohanes Santoso Date: 2007-10-19T17:28:46+09:00 Subject: Re: [OT] Re: Should *most* memory be release back to the system? MenTaLguY writes: > On Fri, 19 Oct 2007 04:13:58 +0900, Joel VanderWerf wrote: >> Yohanes Santoso wrote: >>> mallopt(M_MMAP_THRESHOLD, 0); /* declared in malloc.h */ >> >> Very interesting. I'd like to use this as a diagnostic. >> >> I patched ruby's main.c to call mallopt() before anything else. It seems >> to be using a huge amount of memory, though. Is this normal? > > Using mmap for individual allocations means that each allocation > gets rounded up to the nearest multiple of the page size > (typically 4k). > > That aside, I'm not sure it's that useful as a diagnostic; note > that only M_MMAP_MAX chunks will ever be allocated at a time with > mmap; further allocations beyond that are allocated the normal way > by advancing sbrk. > > -mental I suppose all these could be offered as an extension module. At the very least allow: Malloc.m_mmap_threshold=(),m_mmap_max=(), and stat() which returns wrapped struct mallinfo.[1] This is so you don't have to pay for allocations not done by your app like allocations internal to ruby and/or RoR. From struct mallinfo, it seems you can get the actual memory use with hblkhd + uordblks which would provide yet another way to diagnose the raising VSZ problem. Perhaps mental can confirm this? YS. Footnotes: [1] http://www.gnu.org/software/libc/manual/html_node/Statistics-of-Malloc.html#Statistics-of-Malloc