[uClinux-dev] Reclaiming Memory
Jamie Lokier
jamie at shareable.org
Fri Nov 2 11:47:37 EST 2007
Harry Gunnarsson wrote:
> Hm, you are saying one thing that gets me thinking. I assumed, perhaps
> incorrectly, that the 'chunks' of memory in the power-of-two scheme
> were pre-allocated at kernel start. That is, n * 128k, m * 256k, y *
> 512k etc And I thought that the big chunks of 2M and 4M were also
> pre-allocated at startup and never used for small allocations.
You could change the kernel allocator to do something like that:
pre-allocate large chunks at boot time, and it would solve your
problem.
It's not generally done because in most applications it would be a
poor use of the limited memory.
> I thought that this was the point of the SLAB allocator, i.e. avoiding
> fragmentations with fixed size pre-allocated blocks.
SLAB does do that, but it only avoids some kinds of fragmentation, and
it causes other kinds. Unfortunately, there is no algorithm which can
completely remove fragmentation. The nearest thing would be if all
allocated blocks could be _moved_ on demand, but that's not possible
in Linux, or with C malloc().
> So there is no 'guaranteed' way of making sure the system can deliver
> reliably a 4M chunk of memory over the time of execution, right?
Not really if you have only 32MB total. You can do it if you kill all
processes and free all filesystem caches, but that's nearly the same
as rebooting :-)
-- Jamie
More information about the uClinux-dev
mailing list