free() does not physically trim/reclaim memory

shuxin yang
Fri Sep 2 16:27:00 GMT 2016

Hi, Florian:

On 09/02/2016 04:44 AM, Florian Weimer wrote:
> On 09/01/2016 08:24 PM, shuxin yang wrote:
>>     In my application, I need to call mmap() a block right after BSS in
>> order to prevent heap from growing.
> You cannot rely that this has any observable effect.  Why do you need 
> to do this?

   Our application embeds luajit. Due to some limitations, luajit 
allocates object under 2G;
on x86-64 platform, it is done by calling mmap() with flag MAP_32BIT and 
then cutting
a block out of it. We need to preserve the space (BSS-end, 2G] for 
luajit. That is why
we need to mmap() a tiny block right after BSS right before the main() 
function of the application
is entered.

> Thanks,
> Florian

More information about the Libc-help mailing list