Faster Virtual Method Dispatch
Craig Black
cblack at ara.com
Thu Apr 27 11:16:45 PDT 2006
> I'm not entirely familiar with the concept of allocators as you describe.
> Is this similar to memory pooling? I always skipped over that portion of
> the C++ STL; way too much complexity for my small brain =P.
Instead of calling malloc for each allocation unit, you could write an
allocator class that would allocate memory in large chunks. Then when you
want an allocation unit, you request it from the allocator. The allocator
simply hands out the memory, an marks it as used.
The hierarchical memory system you describe lends itself to using such
custom allocators, because you would never have to call free for each unit.
You could call free at the allocator level instead. In this way, you would
only call malloc and free for large chunks of memory.
You could also inform each allocator how much memory to reserve when they
are created, since you may have a good idea of how much memory a given task
will require.
Did that help?
-Craig
More information about the Digitalmars-d
mailing list