This is the mail archive of the libc-help@sourceware.org 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: Very confused about malloc in Linux, Help!!!


2010/10/11 Shigang Zan <zanshigang@hotmail.com>:
> Then how does malloc know when to create one areana or not? In my system, I feel, program created more and more blocks. What is reason to create them. Normal heap only has 40M, why doesn't extend it but create more high address block. I want to know the behavior of malloc, I found the blocks won't be freed from /proc/*/smaps.

Why do you want to know?

If you are trying to educate yourself, I suggest reading the code.
There are many different heuristics involved in deciding when to
create an arena, we can't answer them in general here.

If you are trying to answer *another* question like "How do I reduce
total virtual memory consumption?" then the answer is going to be
"Write your own malloc." The glibc malloc implementation will allocate
large arenas and if you have threads it will try to use one arena per
thread to increase allocation concurrency.

The malloc in glibc is based on ptmalloc2, which is based on dlmalloc.

This malloc aims to be the fastest while also being among the most
space-conserving (not space saving), portable and tunable malloc.

Cheers,
Carlos.


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