by Niall Douglas. Last updated . This page has been accessed 23,863 times since the 13rd February 2004.
|View this page in:||English||Any language:
Translation to non-English languages provided by Google Language
You are connecting to the IPv4 version of this website from the IP address 220.127.116.11. You can try the IPv6-only version if you want.
ptmalloc2 is one
of the fastest dynamic memory allocators for multithreaded systems around
and also causes remarkably low memory fragmentation. It isn't my code at
all, but in the process of implementing the FXMemoryPool class in
TnFOX I backported it from
glibc to win32.
Therefore this edition of ptmalloc2 compiles for both Windows and POSIX Unix and to my knowledge is the only version of ptmalloc2 available for Windows.
Note: nedmalloc supersedes ptmalloc2 and is a better memory allocator in almost all scenarios
Doug Lea wrote the original dlmalloc and Wolfram Gloger added the per-thread arenas (renaming it to ptmalloc2) to enable the substantial performance gains under multithreaded conditions. I Niall Douglas merged & substantially improved the Win32 support from dlmalloc back into ptmalloc2. There is a report by Sun comparing dynamic allocators which shows just how good ptmalloc2 is. More information on how dlmalloc & ptmalloc2 work is on Doug Lea's website. If you want more info on all dynamic allocators, this is a good link. Also you may wish to read my notes on dynamic allocators in the TnFOX documentation.
There are two versions of this allocator - the safe version and the unsafe version. The safe version is literally glibc's from the v2.3.3 release with the Unix memory management emulations patched in. The unsafe (and older) version is my attempt to merge the latest Doug Lea allocator v2.7.2 with ptmalloc2 (based on v2.7.0 of dlmalloc) - I only generated the safe version because I thought a mistake of mine in my merged version was causing a fault when it actually turned out to be something else entirely. TnFOX uses the safe version as of v0.80 onwards as performance will be sufficient.
Warning: When merging the two sets of source for v2.7.2 I may have made mistakes. I'm pretty confident that no memory corruption occurs after extensive testing, however I am less sure that all the memory freeable is actually freed when it should be. The v2.7.0 glibc port has the advantage of having been very heavily tested as the core allocator for Linux.
For the v2.7.2 port, my enhancements are licensed under the same license as Doug Lea's and Wolfram Gloger's ie; you can use this code for any purpose at all, commercial or non-commercial, closed or open source, without accreditation or any restriction of the production of derived works. For the v2.7.0 port is from glibc and so is purely LGPL.
Note that you should use nedmalloc in preference to ptmalloc2
Not recommended but still available if you want it: