mmalloc is a heap manager. It is written from a scratch. Main goals were
accurate RAM consuming and performance. Goals achieved using relatively
new virtual memory mapping techniques (known in UNIX wolrd as mmap ;-) and
AVL trees.
Major advantages of this heap manager:
- Trimming and "no commit". mmalloc immediately (not in Windows world)
releases all deallocated pages to the system. Also all allocated pages are
not commited, because new areas are just mapped in, still not commited and
only user program could commit memory. So the following rule is real true:
"NO UNUSED MEMORY WILL BE CONSUMED".
- Best-fit. Best-fit strategy was used. As shown in real world
experiments, best-fit proven to be more accurate than first-fit.
- AVL Trees. Primary internal structure used for controlling large
blocks (>256 bytes tunable). So the time consumed by allocating
new block is proportional to O(log N), where N is the
number of memory fragments. Implementation is in pure C and optimized.
- Small blocks grouped. Small blocks are grouped within pages. This
provides more accurate memory consuming. When doing 100000 times mmalloc(1)
only ~130k of real memory will be allocated.
- Smart alignment. Blocks smaller than MALLOC_ALIGN (tunable)
are not aligned. (typical for i386 are blocks < 4 bytes). Other blocks are
aligned by MALLOC_ALIGN.
- Small overhead. For blocks large blocks overhead is 32 bytes. It
is approximately 12.5% for 256 bytes long block. For larger blocks size of
this control structure is ever less noticed. Small blocks are grouped within
one page and resulting overhead is less than 0.2% (8/4096*100).
- Pure ANSI-C. Pure ANSI-C without any extensions was used. So
library should be portable. Only vmm functions are not portable, other library
parts should be.
Comparing to other heap managers. I have no time at right moment to create
good tests, which will emulate some real world applications. So I decided,
that if I publish the sources on the Net, someone will write to me and
propose possible test and/or test results.
E-mail to me.
Stability. This version was tested only on several PCs, so there
may be a bug. Use with caution. I disclaim any warranties. It works for me
OK for about half a year, it doesn't mean that it will work OK to you. But
of course you could try. If you have found any bug, please
e-mail to me.