Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Internet/Indy    [ Add a report in this area ]  
Report #:  88642   Status: Open
IndyRegisterExpectedMemoryLeak crashes with SafeMM
Project:  Delphi Build #:   15.0.3890.3407
Version:    15.0 Submitted By:   Jan Goyvaerts
Report Type:  Crash / Data loss / Total failure Date Reported:  10/4/2010 9:22:42 PM
Severity:    Infrequently encountered problem Last Updated: 9/9/2013 7:00:24 PM
Platform:    All platforms Internal Tracking #:   280700
Resolution: Retest (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
If a Delphi XE application uses SafeMM (an alternative memory manager) and also uses Indy, then the application crashes during the initialization process when IndyRegisterExpectedMemoryLeak is called.

Looking at the code, it seems that IndyRegisterExpectedMemoryLeak uses compiler directives to determine which memory manager is in use rather than detecting the actual memory manager at runtime.  It is not reasonable to expect developers to require to recompile Indy when they want to use a different memory manager, particularly one like SafeMM that is only used for testing.

This is a regression from previous Delphi versions.  In previous Delphi versions applications using Indy run fine with SafeMM.
Steps to Reproduce:
1. Start a new VCL application.
2. Add SafeMMInstall and IdStack to the uses clause of the .dpr file.  SafeMMInstall must be the first unit in the uses clause.
3. Run

Expected: Application runs showing a blank Form1
Actual: Application crashes with an AV

SafeMM can be downloaded at

Tomohiro Takahashi at 10/4/2010 10:03:09 PM -
Is this regression?
With previous version of Delphi(e.g., 2010), this issue does not occur?

> SafeMM can be downloaded at
The page says, "DETAILSFor Delphi, Version 7.0  to 14.0".
Does SafeMM support Delphi XE officially?

Jan Goyvaerts at 10/4/2010 10:10:21 PM -
The issue did not occur in Delphi 2010.

SafeMM works fine with Delphi XE as long as Indy is not used.  It also works fine with Delphi XE if I edit IndyRegisterExpectedMemoryLeak to do nothing but return False.

Have you actually looked at the code in IndyRegisterExpectedMemoryLeak?  It is clearly hard-coded to expect FastMM to be the memory manager.  I am merely using SafeMM as an example.

Remy Lebeau (TeamB) at 9/9/2013 7:00:45 PM -
Indy expects FastMM only when USE_FASTMM4 is defined, which it is not by default.  USE_FASTMM4 use meant for use in Delphi versions prior to 2006, before FastMM was incorporated into the RTL.  USE_FASTMM4 should not be defined in Delphi 2006 and later versions, so that Indy uses System.RegisterExpectedMemoryLeak() instead of FastMM4.RegisterExpectedMemoryLeak() directly, and thus will register memory leaks with whatever memory manger is actually used at runtime.

Server Response from: ETNACODE01