Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Every compiler has its own memory management system. And, to be accurate, you can have several MM working on the same compiler. You can choose which MM to use, depending on your application purpose. For instance, in a Server you may be interested in a multi-thread scaling MM, but on a simple UI Client application, you'd like your MM just to be fast and not memory consuming.</p> <p>The internal Heap management provided by Windows was so slow (at least until XP) that every compiler/framework did implement its own memory manager.</p> <p>For Delphi, there was a "pure Borland" version since 2006, then an Open Source MM, named <a href="http://sourceforge.net/projects/fastmm" rel="nofollow">FastMM4</a>, has been included into the main "Delphi" IDE. </p> <p>With Delphi, it's very easy to change the memory manager. You just create a record of functions, then call the SetMemoryManager() to replace the current MM with the new one.</p> <p>For instance, here is how is installed <a href="http://blog.synopse.info/post/2010/12/04/SynScaleMM" rel="nofollow">our Open Source scaling Memory Manager</a> for Delphi:</p> <pre><code>{$if CompilerVersion &gt;= 17} {$define USEMEMMANAGEREX} {$ifend} var {$ifdef USEMEMMANAGEREX} OldMM: TMemoryManagerEx; {$else} OldMM: TMemoryManager; {$endif} const {$ifdef USEMEMMANAGEREX} ScaleMM_Ex: TMemoryManagerEx = ( GetMem: Scale_GetMem; FreeMem: Scale_FreeMem; ReallocMem: Scale_ReallocMem; AllocMem: Scale_AllocMem; RegisterExpectedMemoryLeak: Scale_RegisterMemoryLeak; UnregisterExpectedMemoryLeak: Scale_UnregisterMemoryLeak ); {$else} ScaleMM_Ex: TMemoryManager = ( GetMem: Scale_GetMem; FreeMem: Scale_FreeMem; ReallocMem: Scale_ReallocMem ); {$endif} procedure ScaleMMInstall; begin // Hook memory Manager GetMemoryManager(OldMM); if @OldMM &lt;&gt; @ScaleMM_Ex then SetMemoryManager(ScaleMM_Ex); // init main thread manager GlobalManager.Init; </code></pre> <p>This code will replace the Delphi MM by our own, via the custom <code>Scale_GetMem</code> / <code>Scale_FreeMem</code> / <code>Scale_ReallocMem</code> / <code>Scale_AllocMem</code> functions. You can just make a wrapper to the old MM by using the <code>OldMM</code> variable:</p> <pre><code>function Scale_GetMem(aSize: Integer): Pointer; begin // do some debugging here result := OldMM.GetMem(aSize); end; </code></pre> <p>The MM record structure changed in time, so you'll have to select the right one - we do this using the <code>USEMEMMANAGEREX</code> conditional.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload