Memory Leak when using ".DelegateTo()"

Issue #104 closed
TheFlow0360 created an issue

After getting mysterious memory leaks in my application, i narrowed them down to be caused by the .DelegateTo() procedure.

To reproduce, simply sue the Demo.SPring.DelegatedConstructor demo project, add FastMM with "ReportMemoryLeaksOnShutdown := True;" and run the project. It will leak "uDelegatedConstructor$3$ActRec x 1" (and a TUser).

Like this, registering any type with ".delegateTo()" causes the a leak of "$[UnitName]$x$ActRec x 1".

Comments (5)

  1. Stefan Glienke repo owner

    My magic crystal ball is telling me that you have the DelegateTo call either in the global main in the dpr or in some initialization part of a unit.

    If that is true then this is not our fault but the compiler/memory manager and is a known issue (which I think will not be addressed - see http://qc.embarcadero.com/wc/qcmain.aspx?d=90194). To work around that write a routine that executes that code and call that whereever you have the code now.

    Edit: Ok, after looking at the code that confirms my guess. I will fix the demos but that will not fix the issue you are having in your application. Also I can just recommend to not put registration code in initialization blocks (I blame the person that wrote bad demo code for teaching people wrong)

  2. Log in to comment