All is working fine. Debug or Release config, my test leak shows up just fine... until I UPX the executable. I left a leak in a frame constructor to check and after UPX, objects do not even show up anymore (only GetMem and UnicodeString) and they point to a unit initialization stack rather than a button click -> frame constructor.
For home, I prohibited MadExcept to adjust project clauses, complier and linker options or conditional defines. I have a small unit which acts as a wrapper for MadExcept, it is added as the first unit in the project:
Unit uMyMadExcept;
Interface
Code: Select all
Uses MadExcept;
Type
TLeakDetectedMethod = Reference To Procedure(Const inLeakText: String);
Var
OnLeakDetected: TLeakDetectedMethod;
Procedure EnableLeakChecking;
Implementation
Uses System.SysUtils;
Procedure EnableLeakChecking;
Begin
WaitForCleanExitProcess(True);
ShowNoLeaksWindow(False);
ShowLeakProgressWindow(False);
SetChildLeakFiltering(True);
StartLeakChecking;
End;
Function GetExceptionStackInfoProc(P: PExceptionRecord): Pointer;
Var
stacktrace: String;
Begin
stacktrace := GetCrashStackTrace(True);
Result := StrAlloc(Length(stacktrace));
StrCopy(Result, PChar(stacktrace));
End;
Function GetStackInfoStringProc(Info: Pointer): String;
Begin
Result := PChar(Info);
End;
Procedure CleanUpStackInfoProc(Info: Pointer);
Begin
StrDispose(PChar(Info));
End;
Initialization
OnLeakDetected := nil;
Exception.GetExceptionStackInfoProc := GetExceptionStackInfoProc;
Exception.GetStackInfoStringProc := GetStackInfoStringProc;
Exception.CleanUpStackInfoProc := CleanUpStackInfoProc;
{$IFDEF DEBUG}
EnableLeakChecking;
{$ENDIF}
Finalization
Exception.GetExceptionStackInfoProc := nil;
Exception.GetStackInfoStringProc := nil;
Exception.CleanUpStackInfoProc := nil;
If Assigned(OnLeakDetected) Then
Begin
OnLeakDetected(MadExcept.GetLeakReport);
StopLeakChecking;
End;
End.
Thanks!