This is the mail archive of the
mailing list for the glibc project.
Re: improving malloc
On Sun, Jan 06, 2013 at 08:45:45AM -0500, Rich Felker wrote:
> On Sun, Jan 06, 2013 at 10:56:18AM +0100, OndÅej BÃlka wrote:
> > > Other considerations are memory fragmentation, how quickly
> > > it can give back unused memory to the OS, etc. etc.
> > >
> > For giving memory back to OS when linux gets volatile ranges then
> > we can finally do not have to defer returning memory because zeroing
> > pages is expensive.
> > I wanted to suggest at linux-kernel to keep pages returned to linux
> > at linked list and for allocations prefer these as they do not have
> > to be zeroed.
> Preferring them is backwards; it will cause more page faults and use
> more memory. Once you've returned memory to the kernel, you should
> avoid using it again unless absolutely necessary. It's _possible_
> that, for some usage cases, calloc would want to use this memory, but
> for malloc it's always a pessimization.
I said something different but perhaps did not say clearly. It is that
kernel will keep freed memory in linked list and when more memory is
requested use freed memory so it does not have to zero it.
Hash table has woodworm