This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc pre-allocated too much memory


Hi,

> >     I'm running a service with very small memory usage (less than 500 
> KB)
> > but a large amount of servicing processes (more than 20 thousand).
> > 
> >     Since we always work hard to reduce the memory usage, we've found 
> that
> > gnu libc's malloc seems to pre-allocate about 128 KB of memory.  (We 
..
> You can also adjust these values at runtime using #include <malloc.h>
...
>         mallopt (M_TOP_PAD, MY__TOP_PAD);

Exactly, either that or perhaps even simpler set MALLOC_TOP_PAD_=0 in
the environment (perhaps necessary because memory might be allocated
before main() and then you would already have the pre-allocated
chunk).

Also note that this will really only save memory on non-paging
architectures -- the "pre-allocated" memory actually shouldn't be
dirtied by malloc except for the first and last page.

Regards,
Wolfram.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]