[fpc-devel]Re [2]: Some more compiler problems

Peter Vreman peter at freepascal.org
Wed Apr 4 17:54:19 CEST 2001


> BTW, can you briefly explain work of built in FPC memory manager (what
> kind of trees are used if any, etc)? Just wanted to know - maybe
> there's some place for the development...

all list are double-linkedlists. Every unused block is one of the freelists. For blocks <
1024 there is a list for each size. For other blocks there is a general list.

Out of one of the freelist are the blocks allocated. When no free block is found a new
block from the OS is requested.

When blocks are freed they are merge together with their next neighboor.

To expiriment you can just copy the routines from heap.inc and create an own memorymanager
(see heaptrc.pp) that can be plugged in. Instead of requesting blocks from the OS you can
than request big blocks from the internal heapmanager.


Possible optimizations:

- Better handling of end of OS memoryblock. This is currently done by a flag that also
needs inheritance handling when merging. Maybe allocating a small block at the end will
make this more simple.

- Deffered merging

For more memory allocation info look at the malloc implementation from Doug Lea
http://gee.cs.oswego.edu/dl/html/malloc.html








More information about the fpc-devel mailing list