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/9 Shigang Zan <zanshigang@hotmail.com>:
> So my question is:
>
> 1. What malloc did do to cause scenario 2? Both 1 and 2 are multi-thread program.

Malloc may be using already allocated arenas to allocate your blocks.
This shouldn't be a problem and will not effect the performance of
your program.

> 2. Can malloc free memory well in scenario 2?

Yes.

If you have a problem you need to provide a test case.

Malloc may keep an arena around like a cache to avoid future mmaps.

Please keep in mind that POSIX says free will ensure that space is
"made available for further allocation," but it doesn't say it is
given back to the OS.

You have to allow the OSs VM to handle things.

If you need more explicit control, write your own malloc.

Cheers,
Carlos.


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