Question about freeing segments in non contiguous main_arena
Abhijit Ray Chaudhury
abhijit.ray.chaudhury@gmail.com
Wed May 6 05:23:46 GMT 2026
Hi Florian,
Thanks a lot for your reply. In the case of non-contiguous main_arena ,
assume the av->top points to a mmapped segment. Application started freeing
the memory in the order of allocation . av->top starts getting adjusted .
Since it is not heap_info structure you don't know the base address of the
segment. Would munmap be called ?
If it is not called, would we leak the virtual address space ? How is the
address space supported to be reclaimed ? Is it a bug then ?
Kindly let me know your thoughts.
Thanks in advance,
-Abhijit
On Tue, 5 May, 2026, 10:18 pm Florian Weimer, <fweimer@redhat.com> wrote:
> * Abhijit Ray Chaudhury:
>
> > Hi Florian,
> >
> > Thanks a lot for your reply. When an application starts freeing memory
> > and frees all the memory for one mmaped segment , where av->top
> > currently points to , how av->top be adjusted ?
> >
> > My assumption is that if all the memory is freed by the application
> > that belongs to main_arena , av->top should go back to the contiguous
> > [heap] segment . This question pertains to the non-contiguous
> > main_arena scenario .
>
> I don't think this happens in the current implementation. I'm not aware
> of any data structures maintained by the code that would readily support
> this.
>
> Thanks,
> Florian
>
>
More information about the Libc-help
mailing list