Delphi 2007 unit initialization problem

Help
2009-07-21
2013-05-23
  • Hi all,

    Risking a silly question.

    I'm trying to swap in the current version of FastMM4 (4.92) into my Delphi 2007 project.  Many dlls, all with FastMM4 as the first unit in their uses clause.  I've checked their .dpr files, turned off everything using madExcept, but I still get hit with the usual error:

    "FastMM4 cannot install since memory has already been allocated through the default memory manager.  FastMM4.pas MUST be the first unit in your project's .dpr file, otherwise..."

    Stepping through with the debugger, I *have* noticed that before FastMM4 gets hit, the System unit is the first to be initialized.

    And it's initialization section?  The first line is this:

    "initialization
      InitializeMemoryManager;"

    This goes off into the default GETMEM.INC.  Not my new, shiny FastMM4 4.92 code.

    Am I actually meant to overwrite this with FastMM4.pas, to use the newer version?  I can't see a way to beat the System.pas initialization to the memory manager installation.

    Thanks for any help.

     
    • Ah.. yep.  Silly question.  The problem is definitely my end.  Missed a statically linked dll, which pulls in some other units (eg. SysUtils, Classes, etc) before the FastMM4 unit gets a chance to load up.

      Removing this fixes things, so I'm assuming this was the hiccup. 

      Am now seeing some lovely, lovely stack traces. :)