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]

malloc_trim() behaviour


Hello,

I've got a question about the actual behaviour of malloc_trim().

man malloc_trim says:
[...]
malloc_trim - release free memory from the top of the heap
[...]
This function cannot release free memory located at places other than
the top of the heap.
[...]

Today I've looked that the implementation of malloc_trim()
malloc/malloc.c and I am a bit puzzled now as its (as far)
as I can see not the behaviour described in its man page.

__malloc_trim() calls mtrim which makes use of
__madvise (paligned_mem, size & ~psm1, MADV_DONTNEED);

My understanding is that madvise(MADV_DONTNEED) would allow
me to release a range of memory back to the OS. This range
wouldn't need to be at the top of the heap.

Is the man-page outdated? Am I looking at the wrong place?
What is the actual behaviour of malloc_trim()?

Kind Regards,
Frank


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