Memory allocator change

When running a userspace program, the kernel has to allocate a continuous block of memory to store the code, data and stack.

The default memory allocator in the 2.6 branch of the linux kernel is called SLAB.
The SLAB allocator rounds this allocation up to the next size it deals with.
The SLAB allocator uses sizes of 32, 64, 96, 128, 192, 256 and 512 bytes and 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024 kilobytes.

So if a program requires 70k of memory, the SLAB allocator would allocate 128k.

This wastes a lot of memory.

There is an alternative memory allocator called SLOB.

SLOB allocates what you ask for and doesn’t waste memory.

The SLOB allocator has been added to DSLinux and will be used in the next nightly build.

Using SLOB will allow retawq to run on the GBAMP build again.

10 Responses to “Memory allocator change”

  1. Dualscreenman Says:

    Cool. This will optimize memory usage in all builds?

    *Bad Pun Warinng*

    It seems in this case that “SLAB” really is the SLOB here. :p

  2. Parasite Says:

    Never thought this kind of scheduler is a default in uClinux! Thanks for the hint, I’ll try using SLOB on a router where I constantly have “out of memory” issues.

    Dslinux is really having a sprint now XIP is implemented!

  3. Scor Says:

    Good call :) .
    Shaves off a lot of memory usidge.
    Not that I have any use for it a.t.m., since I still can’t acces my router with WEP, but this will also create more memory for nano I gues.

  4. Shlee Says:

    LinuxTiny is the collection of the patches to reduce the system size and memory consumption of the Kernel.

    http://www.celinuxforum.org/CelfPubWiki/JapanTechnicalJamboree3?action=AttachFile&do=get&target=linutiny_celfJtechJ3_en.pdf

    Worth a read?

  5. Shlee Says:

    http://tree.celinuxforum.org/CelfPubWiki Worth reading aswell

  6. AndrewNeo Says:

    Why exactly would a 70k program allocate 128k when 96k is the next highest?

  7. Daniel De Matteis Says:

    AndrewNeo: I think that’s 96 bytes as opposed to 96k.

  8. Kenny Says:

    AndrewNeo: dont think about it :P

  9. Kenny Says:

    figured it out.
    theres 96 bytes, not 96 kilobytes.
    he said if it required 70 kilobytes not bytes

  10. swimgod Says:

    AndrewNeo:
    The SLAB allocator uses sizes of 32, 64, 96, 128, 192, 256 and 512 BYTES!

    1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024 KiloBytes.

    lol,
    see if it was in bytes it would be 96, but its in KB so its 128
    :P
    miss read man :P