Updates to the containers library



I have been reworking the heap allocation module. This module should be
the base of many containers since it is specialized in allocating a lot
of objects all of the same size.


I have discarded the bitmap I maintained to track the free list for a
slightly more sophisticated approach.

I allocate a table of pointers to pages of CHUNK_SIZE objects. Since one of the constraints is that no active object can be moved, it is not
possible to just allocate a single strip of objects and reallocate it
later. The reason for maintaining active objects fixed is that user
pointers to those objects could exist and that there is no way to
update those if the object is moved.

The organization is then :

A resizable vector of pointers that holds the start addresses of pages
of a fixed quantity of allocated objects.

When an object is freed, its "Next" pointer will be updated to
contain INVALID_POINTER_VALUE, that for the time being I have defined
as ((void *)~0ULL). This allows me to distinguish active objects
from freed ones, assuming that all client objects have a pointer at
their first position. This is always true for the containers, but limits the interest of this schema for other uses.

The heap contans an implementation of iterators, that allow a client
program to visit all objects in the heap. Since all complex containers
like trees, (scapegoat trees) and others use a heap, I get an
implementation of iterators in all those containers for free without
having to write an iterator for each one.


The source code is available at

http://code.google.com/p/ccl/

The code size has been reduced: all the heap object takes now
around 1500 bytes of code in a x86.

jacob

.



Relevant Pages

  • Re: Help wanted - problems with heap
    ... Memory pressure, because of limited heap size. ... identified that by failures to allocate memory. ... Any pointers as to work out what is happening would be welcome. ...
    (rec.games.roguelike.development)
  • Re: Is libcs |malloc()| MPSS-aware ?
    ... > and doesn't allocate larger containers (from which smaller ... > size is set for the heap (I would expect that then the container size is ... The physical processor has 1 virtual processor ...
    (comp.unix.solaris)
  • Question on Fortran implementation of very large array heaps (optimal minimization)
    ... arrays (not linked lists), but as the size requirements of the heap ... -- A linked list (pointers) where nodes are added and removed as the ... allocate the heap so as to reduce CPU usage/time (not necessarily ...
    (comp.lang.fortran)
  • Re: Huge pages and small pages. . .
    ... >> what looks like contiguous memory and away you go. ... you need to have them cached in the TLB; if the TLB runs out of ... > low end of the heap, until someone figures out a way to tell the system ... When you allocate memory, the kernel just marks a promised ...
    (Linux-Kernel)
  • Re: Struct inside class
    ... The compiler figures computes the ... including anything derived from "Object": Heap pointer ... memory leaks and why the .NET good garbage collector is required. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)