I wanted to build a replacement library for borlndmm.dll, the memory manager library for Delphi and C++ Builder applications. My primary reason was the need to improve the performance of a multi threaded application which performs many dynamic allocations in the worker threads. The default borlndmm library is based around some version of FastMM and my testing was showing that its performance was poor for multi threaded scenarios, even when setting System::NeverSleepOnMMThreadContention to true, which forces the allocator to spin upon contention rather then perform a context switch to the kernel via the kernel32!Sleep function (Which is an insane design choice IMHO!). I also wanted to better control some additional debugging capabilities, specifically I wanted to be able to poison a newly allocated heap block with some non NULL value so as to help identify uninitialised variable access as well as poison a freed allocation with some non NULL value to help identify use after free scenarios. The non NULL values chosen are high bytes, 0xA1 for new allocations and 0xF1 for freed blocks, so if used as a pointer will trigger an access violation.Other benefits of using the native Windows heap for allocations include the builtin security mitigation's in the native heap which do clever things like encode pointers and move sensitive heap metadata out of line from the heap blocks so they cannot be targeted for corruption during a heap based buffer overflow. Additionally you can now use tools like WinDbg to query and debug heap allocation issues, which I have found to be useful at times. The only pain here is WinDbg will require either PDB or DBG files for symbol information so your TDS or MAP files will need to be converted via some tool like map2dbg. If only the RAD Studio tool chain supported normal Windows development formats like PDB symbols.Having built a custom borlndmm.dll to achieve the above, I was able to identify several uninitialised variable bugs in my code base as well as several use after free issues. Hurrah! Most importantly the performance of my application has measurably improved, so the effort of shipping a custom borlndmm.dll with the product has been worth it.I have posted the code up on GitHub: