8
votes

Has anyone ported the SafeMM debugging memory manager to Delphi XE2? The 2009 SafeMM on CodeCentral won't compile because the RTL now uses NativeInt instead of Integer for the memory functions.

1
Have you not considered just changing the declarations of Integer to NativeInt where appropriate?LaKraven
I'm not sure it's going to be that simple. I figured I'd ask if anyone already ported SafeMM to Win64 before I try to do it myself, so I don't needlessly duplicate other people's effort.Jan Goyvaerts
Don't most people use [FastMM] (sourceforge.net/projects/fastmm) in full debug mode these days? It seems to catch pretty much all nasties I've ever thrown at it and is fully XE2 and 64-bit.Brian Frost
If you do port it, I'd be curious if 64 bit Windows apps [since they can allocate more than 2 gigs of RAM] would be a really great way to enable memory-safety-testing. With SafeMM, I hit the 2 gb limit very quickly, on applications with heaps around 100 megabytes of actual heap space, SafeMM consumed > 2 gb.Warren P
@WarrenP: A Win64 app using SafeMM will be able to use all of the PC's memory, so it will have more headroom than the same app compiled for Win32.Jan Goyvaerts

1 Answers

4
votes

I've uploaded my Delphi XE2 port of SafeMM to CodeCentral. I've verified that it correctly allocates blocks larger than 4 GB and that it can allocate more than 4 GB worth of smaller blocks when used in a Win64 application and that it still works correctly in Win32 applications.

I've updated my CodeCentral submission on 7 July 2012 to fix a bug that causes SafeMM to crash when two threads try to free a large block (> 4KB) at the same time. This bug was introduced in version 0.3 of SafeMM by its original developer. If you're using this version of SafeMM with an older version of Delphi, you'll need to wrap the code in FreeLargeBlock in a critical section as I did in my version.