BorlndMM.dpr 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. {
  2. Fast Memory Manager: Replacement BorlndMM.DLL 1.05
  3. Description:
  4. A replacement borlndmm.dll using FastMM instead of the RTL MM. This DLL may be
  5. used instead of the default DLL together with your own applications or the
  6. Delphi IDE, making the benefits of FastMM available to them.
  7. Usage:
  8. 1) Make sure the "NeverUninstall" conditional define is set in FastMM4.pas if
  9. you intend to use the DLL with the Delphi IDE, otherwise it must be off.
  10. 2) Compile this DLL
  11. 3) Ship it with your existing applications that currently uses the borlndmm.dll
  12. file that ships with Delphi for an improvement in speed.
  13. 4) Copy it over the current borlndmm.dll in the Delphi \Bin\ directory (after
  14. renaming the old one) to speed up the IDE.*
  15. Acknowledgements:
  16. - Arthur Hoornweg for notifying me of the image base being incorrect for
  17. borlndmm.dll.
  18. - Cord Schneider for notifying me of the compilation error under Delphi 5.
  19. Change log:
  20. Version 1.00 (28 June 2005):
  21. - Initial release.
  22. Version 1.01 (30 June 2005):
  23. - Added an unofficial patch for QC#14007 that prevented a replacement
  24. borlndmm.dll from working together with Delphi 2005.
  25. - Added the "NeverUninstall" option in FastMM4.pas to circumvent QC#14070,
  26. which causes an A/V on shutdown of Delphi if FastMM uninstalls itself in the
  27. finalization code of FastMM4.pas.
  28. Version 1.02 (19 July 2005):
  29. - Set the imagebase to $00D20000 to avoid relocation on load (and thus allow
  30. sharing of the DLL between processes). (Thanks to Arthur Hoornweg.)
  31. Version 1.03 (10 November 2005):
  32. - Added exports for AllocMem and leak (un)registration
  33. Version 1.04 (22 December 2005):
  34. - Fixed the compilation error under Delphi 5. (Thanks to Cord Schneider.)
  35. Version 1.05 (23 February 2006):
  36. - Added some exports to allow access to the extended FullDebugMode
  37. functionality in FastMM.
  38. *For this replacement borlndmm.dll to work together with Delphi 2005, you will
  39. need to apply the unofficial patch for QC#14007. To compile a replacement
  40. borlndmm.dll for use with the Delphi IDE the "NeverUninstall" option must be
  41. set (to circumvent QC#14070). For other uses the "NeverUninstall" option
  42. should be disabled. For a list of unofficial patches for Delphi 2005 (and
  43. where to get them), refer to the FastMM4_Readme.txt file.
  44. }
  45. {--------------------Start of options block-------------------------}
  46. {Set the following option to use the RTL MM instead of FastMM. Setting this
  47. option makes this replacement DLL almost identical to the default
  48. borlndmm.dll, unless the "FullDebugMode" option is also set.}
  49. {.$define UseRTLMM}
  50. {--------------------End of options block-------------------------}
  51. {$Include FastMM4Options.inc}
  52. {Cannot use the RTL MM with full debug mode}
  53. {$ifdef FullDebugMode}
  54. {$undef UseRTLMM}
  55. {$endif}
  56. {Set the correct image base}
  57. {$IMAGEBASE $00D20000}
  58. library BorlndMM;
  59. {$ifndef UseRTLMM}
  60. uses
  61. FastMM4 in 'FastMM4.pas',
  62. FastMM4Messages in 'FastMM4Messages.pas';
  63. {$endif}
  64. {$R *.RES}
  65. function GetAllocMemCount: integer;
  66. begin
  67. {Return stats for the RTL MM only}
  68. {$ifdef UseRTLMM}
  69. Result := System.AllocMemCount;
  70. {$else}
  71. Result := 0;
  72. {$endif}
  73. end;
  74. function GetAllocMemSize: integer;
  75. begin
  76. {Return stats for the RTL MM only}
  77. {$ifdef UseRTLMM}
  78. Result := System.AllocMemSize;
  79. {$else}
  80. Result := 0;
  81. {$endif}
  82. end;
  83. procedure DumpBlocks;
  84. begin
  85. {Do nothing}
  86. end;
  87. function HeapRelease: Integer;
  88. begin
  89. {Do nothing}
  90. Result := 2;
  91. end;
  92. function HeapAddRef: Integer;
  93. begin
  94. {Do nothing}
  95. Result := 2;
  96. end;
  97. function DummyRegisterAndUnregisterExpectedMemoryLeak(ALeakedPointer: Pointer): boolean;
  98. begin
  99. Result := False;
  100. end;
  101. exports
  102. GetAllocMemSize name 'GetAllocMemSize',
  103. GetAllocMemCount name 'GetAllocMemCount',
  104. {$ifndef UseRTLMM}
  105. FastGetHeapStatus name 'GetHeapStatus',
  106. {$else}
  107. System.GetHeapStatus name 'GetHeapStatus',
  108. {$endif}
  109. DumpBlocks name 'DumpBlocks',
  110. System.ReallocMemory name 'ReallocMemory',
  111. System.FreeMemory name 'FreeMemory',
  112. System.GetMemory name 'GetMemory',
  113. {$ifndef UseRTLMM}
  114. {$ifndef FullDebugMode}
  115. FastReallocMem name '@Borlndmm@SysReallocMem$qqrpvi',
  116. FastFreeMem name '@Borlndmm@SysFreeMem$qqrpv',
  117. FastGetMem name '@Borlndmm@SysGetMem$qqri',
  118. FastAllocMem name '@Borlndmm@SysAllocMem$qqri',
  119. {$else}
  120. DebugReallocMem name '@Borlndmm@SysReallocMem$qqrpvi',
  121. DebugFreeMem name '@Borlndmm@SysFreeMem$qqrpv',
  122. DebugGetMem name '@Borlndmm@SysGetMem$qqri',
  123. DebugAllocMem name '@Borlndmm@SysAllocMem$qqri',
  124. {$endif}
  125. {$ifdef EnableMemoryLeakReporting}
  126. RegisterExpectedMemoryLeak(ALeakedPointer: Pointer) name '@Borlndmm@SysRegisterExpectedMemoryLeak$qqrpi',
  127. UnregisterExpectedMemoryLeak(ALeakedPointer: Pointer) name '@Borlndmm@SysUnregisterExpectedMemoryLeak$qqrpi',
  128. {$else}
  129. DummyRegisterAndUnregisterExpectedMemoryLeak name '@Borlndmm@SysRegisterExpectedMemoryLeak$qqrpi',
  130. DummyRegisterAndUnregisterExpectedMemoryLeak name '@Borlndmm@SysUnregisterExpectedMemoryLeak$qqrpi',
  131. {$endif}
  132. {$else}
  133. System.SysReallocMem name '@Borlndmm@SysReallocMem$qqrpvi',
  134. System.SysFreeMem name '@Borlndmm@SysFreeMem$qqrpv',
  135. System.SysGetMem name '@Borlndmm@SysGetMem$qqri',
  136. {$ifdef VER180};
  137. System.SysAllocMem name '@Borlndmm@SysAllocMem$qqri',
  138. System.SysRegisterExpectedMemoryLeak name '@Borlndmm@SysRegisterExpectedMemoryLeak$qqrpi',
  139. System.SysUnregisterExpectedMemoryLeak name '@Borlndmm@SysUnregisterExpectedMemoryLeak$qqrpi',
  140. {$else}
  141. System.AllocMem name '@Borlndmm@SysAllocMem$qqri',
  142. DummyRegisterAndUnregisterExpectedMemoryLeak name '@Borlndmm@SysRegisterExpectedMemoryLeak$qqrpi',
  143. DummyRegisterAndUnregisterExpectedMemoryLeak name '@Borlndmm@SysUnregisterExpectedMemoryLeak$qqrpi',
  144. {$endif}
  145. {$endif}
  146. {$ifdef FullDebugMode}
  147. SetMMLogFileName,
  148. GetCurrentAllocationGroup,
  149. PushAllocationGroup,
  150. PopAllocationGroup,
  151. LogAllocatedBlocksToFile,
  152. {$endif}
  153. HeapRelease name '@Borlndmm@HeapRelease$qqrv',
  154. HeapAddRef name '@Borlndmm@HeapAddRef$qqrv';
  155. begin
  156. IsMultiThread := True;
  157. end.