FastMM4Options_Debug.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. {
  2. Fast Memory Manager: Options Include File
  3. Set the default options for FastMM here.
  4. }
  5. {---------------------------Miscellaneous Options-----------------------------}
  6. {Enable this define to align all blocks on 16 byte boundaries so aligned SSE
  7. instructions can be used safely. If this option is disabled then some of the
  8. smallest block sizes will be 8-byte aligned instead which may result in a
  9. reduction in memory usage. Medium and large blocks are always 16-byte aligned
  10. irrespective of this setting.}
  11. {.$define Align16Bytes}
  12. {Enable to use faster fixed-size move routines when upsizing small blocks.
  13. These routines are much faster than the Borland RTL move procedure since they
  14. are optimized to move a fixed number of bytes. This option may be used
  15. together with the FastMove library for even better performance.}
  16. {$define UseCustomFixedSizeMoveRoutines}
  17. {Enable this option to use an optimized procedure for moving a memory block of
  18. an arbitrary size. Disable this option when using the Fastcode move
  19. ("FastMove") library. Using the Fastcode move library allows your whole
  20. application to gain from faster move routines, not just the memory manager. It
  21. is thus recommended that you use the Fastcode move library in conjunction with
  22. this memory manager and disable this option.}
  23. {$define UseCustomVariableSizeMoveRoutines}
  24. {Enable this option to only install FastMM as the memory manager when the
  25. application is running inside the Delphi IDE. This is useful when you want
  26. to deploy the same EXE that you use for testing, but only want the debugging
  27. features active on development machines. When this option is enabled and
  28. the application is not being run inside the IDE debugger, then the default
  29. Delphi memory manager will be used (which, since Delphi 2006, is FastMM
  30. without FullDebugMode.}
  31. {.$define InstallOnlyIfRunningInIDE}
  32. {Due to QC#14070 ("Delphi IDE attempts to free memory after the shutdown code
  33. of borlndmm.dll has been called"), FastMM cannot be uninstalled safely when
  34. used inside a replacement borlndmm.dll for the IDE. Setting this option will
  35. circumvent this problem by never uninstalling the memory manager.}
  36. {.$define NeverUninstall}
  37. {Set this option when you use runtime packages in this application or library.
  38. This will automatically set the "AssumeMultiThreaded" option. Note that you
  39. have to ensure that FastMM is finalized after all live pointers have been
  40. freed - failure to do so will result in a large leak report followed by a lot
  41. of A/Vs. (See the FAQ for more detail.) You may have to combine this option
  42. with the NeverUninstall option.}
  43. {.$define UseRuntimePackages}
  44. {-----------------------Concurrency Management Options------------------------}
  45. {Enable to always assume that the application is multithreaded. Enabling this
  46. option will cause a significant performance hit with single threaded
  47. applications. Enable if you are using multi-threaded third party tools that do
  48. not properly set the IsMultiThread variable. Also set this option if you are
  49. going to share this memory manager between a single threaded application and a
  50. multi-threaded DLL.}
  51. {$define AssumeMultiThreaded}
  52. {Enable this option to not call Sleep when a thread contention occurs. This
  53. option will improve performance if the ratio of the number of active threads
  54. to the number of CPU cores is low (typically < 2). With this option set a
  55. thread will usually enter a "busy waiting" loop instead of relinquishing its
  56. timeslice when a thread contention occurs, unless UseSwitchToThread is
  57. also defined (see below) in which case it will call SwitchToThread instead of
  58. Sleep.}
  59. {$define NeverSleepOnThreadContention}
  60. {Set this option to call SwitchToThread instead of sitting in a "busy waiting"
  61. loop when a thread contention occurs. This is used in conjunction with the
  62. NeverSleepOnThreadContention option, and has no effect unless
  63. NeverSleepOnThreadContention is also defined. This option may improve
  64. performance with many CPU cores and/or threads of different priorities. Note
  65. that the SwitchToThread API call is only available on Windows 2000 and later.}
  66. {$define UseSwitchToThread}
  67. {-----------------------------Debugging Options-------------------------------}
  68. {Enable this option to suppress the generation of debug info for the
  69. FastMM4.pas unit. This will prevent the integrated debugger from stepping into
  70. the memory manager code.}
  71. {.$define NoDebugInfo}
  72. {Enable this option to suppress the display of all message dialogs. This is
  73. useful in service applications that should not be interrupted.}
  74. {.$define NoMessageBoxes}
  75. {Set this option to use the Windows API OutputDebugString procedure to output
  76. debug strings on startup/shutdown and when errors occur.}
  77. {.$define UseOutputDebugString}
  78. {Set this option to use the assembly language version which is faster than the
  79. pascal version. Disable only for debugging purposes. Setting the
  80. CheckHeapForCorruption option automatically disables this option.}
  81. {$define ASMVersion}
  82. {FastMM always catches attempts to free the same memory block twice, however it
  83. can also check for corruption of the memory heap (typically due to the user
  84. program overwriting the bounds of allocated memory). These checks are
  85. expensive, and this option should thus only be used for debugging purposes.
  86. If this option is set then the ASMVersion option is automatically disabled.}
  87. {.$define CheckHeapForCorruption}
  88. {Enable this option to catch attempts to perform MM operations after FastMM has
  89. been uninstalled. With this option set when FastMM is uninstalled it will not
  90. install the previous MM, but instead a dummy MM handler that throws an error
  91. if any MM operation is attempted. This will catch attempts to use the MM
  92. after FastMM has been uninstalled.}
  93. {$define DetectMMOperationsAfterUninstall}
  94. {Set the following option to do extensive checking of all memory blocks. All
  95. blocks are padded with both a header and trailer that are used to verify the
  96. integrity of the heap. Freed blocks are also cleared to to ensure that they
  97. cannot be reused after being freed. This option slows down memory operations
  98. dramatically and should only be used to debug an application that is
  99. overwriting memory or reusing freed pointers. Setting this option
  100. automatically enables CheckHeapForCorruption and disables ASMVersion.
  101. Very important: If you enable this option your application will require the
  102. FastMM_FullDebugMode.dll library. If this library is not available you will
  103. get an error on startup.}
  104. {.$define FullDebugMode}
  105. {Set this option to perform "raw" stack traces, i.e. check all entries on the
  106. stack for valid return addresses. Note that this is significantly slower
  107. than using the stack frame tracing method, but is usually more complete. Has
  108. no effect unless FullDebugMode is enabled}
  109. {$define RawStackTraces}
  110. {Set this option to check for user code that uses an interface of a freed
  111. object. Note that this will disable the checking of blocks modified after
  112. being freed (the two are not compatible). This option has no effect if
  113. FullDebugMode is not also enabled.}
  114. {.$define CatchUseOfFreedInterfaces}
  115. {Set this option to log all errors to a text file in the same folder as the
  116. application. Memory errors (with the FullDebugMode option set) will be
  117. appended to the log file. Has no effect if "FullDebugMode" is not set.}
  118. {$define LogErrorsToFile}
  119. {Set this option to log all memory leaks to a text file in the same folder as
  120. the application. Memory leak reports (with the FullDebugMode option set)
  121. will be appended to the log file. Has no effect if "LogErrorsToFile" and
  122. "FullDebugMode" are not also set. Note that usually all leaks are always
  123. logged, even if they are "expected" leaks registered through
  124. AddExpectedMemoryLeaks. Expected leaks registered by pointer may be excluded
  125. through the HideExpectedLeaksRegisteredByPointer option.}
  126. {$define LogMemoryLeakDetailToFile}
  127. {Deletes the error log file on startup. No effect if LogErrorsToFile is not
  128. also set.}
  129. {.$define ClearLogFileOnStartup}
  130. {Loads the FASTMM_FullDebugMode.dll dynamically. If the DLL cannot be found
  131. then stack traces will not be available. Note that this may cause problems
  132. due to a changed DLL unload order when sharing the memory manager. Use with
  133. care.}
  134. {.$define LoadDebugDLLDynamically}
  135. {.$define DoNotInstallIfDLLMissing}
  136. {If the FastMM_FullDebugMode.dll file is not available then FastMM will not
  137. install itself. No effect unless FullDebugMode and LoadDebugDLLDynamically
  138. are also defined.}
  139. {FastMM usually allocates large blocks from the topmost available address and
  140. medium and small blocks from the lowest available address (This reduces
  141. fragmentation somewhat). With this option set all blocks are always
  142. allocated from the highest available address. If the process has a >2GB
  143. address space and contains bad pointer arithmetic code, this option should
  144. help to catch those errors sooner.}
  145. {$define AlwaysAllocateTopDown}
  146. {Disables the logging of memory dumps together with the other detail for
  147. memory errors.}
  148. {.$define DisableLoggingOfMemoryDumps}
  149. {If FastMM encounters a problem with a memory block inside the FullDebugMode
  150. FreeMem handler then an "invalid pointer operation" exception will usually
  151. be raised. If the FreeMem occurs while another exception is being handled
  152. (perhaps in the try.. finally code) then the original exception will be
  153. lost. With this option set FastMM will ignore errors inside FreeMem when an
  154. exception is being handled, thus allowing the original exception to
  155. propagate.}
  156. {$define SuppressFreeMemErrorsInsideException}
  157. {Adds support for notification of memory manager events in FullDebugMode.
  158. With this define set, the application may assign the OnDebugGetMemFinish,
  159. OnDebugFreeMemStart, etc. callbacks in order to be notified when the
  160. particular memory manager event occurs.}
  161. {.$define FullDebugModeCallBacks}
  162. {---------------------------Memory Leak Reporting-----------------------------}
  163. {Set this option to enable reporting of memory leaks. Combine it with the two
  164. options below for further fine-tuning.}
  165. {$define EnableMemoryLeakReporting}
  166. {Set this option to suppress the display and logging of expected memory leaks
  167. that were registered by pointer. Leaks registered by size or class are often
  168. ambiguous, so these expected leaks are always logged to file (in
  169. FullDebugMode with the LogMemoryLeakDetailToFile option set) and are never
  170. hidden from the leak display if there are more leaks than are expected.}
  171. {$define HideExpectedLeaksRegisteredByPointer}
  172. {Set this option to require the presence of the Delphi IDE to report memory
  173. leaks. This option has no effect if the option "EnableMemoryLeakReporting"
  174. is not also set.}
  175. {.$define RequireIDEPresenceForLeakReporting}
  176. {Set this option to require the program to be run inside the IDE debugger to
  177. report memory leaks. This option has no effect if the option
  178. "EnableMemoryLeakReporting" is not also set. Note that this option does not
  179. work with libraries, only EXE projects.}
  180. {$define RequireDebuggerPresenceForLeakReporting}
  181. {Set this option to require the presence of debug info ($D+ option) in the
  182. compiled unit to perform memory leak checking. This option has no effect if
  183. the option "EnableMemoryLeakReporting" is not also set.}
  184. {.$define RequireDebugInfoForLeakReporting}
  185. {Set this option to enable manual control of the memory leak report. When
  186. this option is set the ReportMemoryLeaksOnShutdown variable (default = false)
  187. may be changed to select whether leak reporting should be done or not. When
  188. this option is selected then both the variable must be set to true and the
  189. other leak checking options must be applicable for the leak checking to be
  190. done.}
  191. {.$define ManualLeakReportingControl}
  192. {Set this option to disable the display of the hint below the memory leak
  193. message.}
  194. {.$define HideMemoryLeakHintMessage}
  195. {--------------------------Instruction Set Options----------------------------}
  196. {Set this option to enable the use of MMX instructions. Disabling this option
  197. will result in a slight performance hit, but will enable compatibility with
  198. AMD K5, Pentium I and earlier CPUs. MMX is currently only used in the variable
  199. size move routines, so if UseCustomVariableSizeMoveRoutines is not set then
  200. this option has no effect.}
  201. {$define EnableMMX}
  202. {Set this option to force the use of MMX instructions without checking
  203. whether the CPU supports it. If this option is disabled then the CPU will be
  204. checked for compatibility first, and if MMX is not supported it will fall
  205. back to the FPU move code. Has no effect unless EnableMMX is also set.}
  206. {.$define ForceMMX}
  207. {-----------------------Memory Manager Sharing Options------------------------}
  208. {Allow sharing of the memory manager between a main application and DLLs that
  209. were also compiled with FastMM. This allows you to pass dynamic arrays and
  210. long strings to DLL functions provided both are compiled to use FastMM.
  211. Sharing will only work if the library that is supposed to share the memory
  212. manager was compiled with the "AttemptToUseSharedMM" option set. Note that if
  213. the main application is single threaded and the DLL is multi-threaded that you
  214. have to set the IsMultiThread variable in the main application to true or it
  215. will crash when a thread contention occurs. Note that statically linked DLL
  216. files are initialized before the main application, so the main application may
  217. well end up sharing a statically loaded DLL's memory manager and not the other
  218. way around. }
  219. {$define ShareMM}
  220. {Allow sharing of the memory manager by a DLL with other DLLs (or the main
  221. application if this is a statically loaded DLL) that were also compiled with
  222. FastMM. Set this option with care in dynamically loaded DLLs, because if the
  223. DLL that is sharing its MM is unloaded and any other DLL is still sharing
  224. the MM then the application will crash. This setting is only relevant for
  225. DLL libraries and requires ShareMM to also be set to have any effect.
  226. Sharing will only work if the library that is supposed to share the memory
  227. manager was compiled with the "AttemptToUseSharedMM" option set. Note that
  228. if DLLs are statically linked then they will be initialized before the main
  229. application and then the DLL will in fact share its MM with the main
  230. application. This option has no effect unless ShareMM is also set.}
  231. {$define ShareMMIfLibrary}
  232. {Define this to attempt to share the MM of the main application or other loaded
  233. DLLs in the same process that were compiled with ShareMM set. When sharing a
  234. memory manager, memory leaks caused by the sharer will not be freed
  235. automatically. Take into account that statically linked DLLs are initialized
  236. before the main application, so set the sharing options accordingly.}
  237. {$define AttemptToUseSharedMM}
  238. {Define this to enable backward compatibility for the memory manager sharing
  239. mechanism used by Delphi 2006 and 2007, as well as older FastMM versions.}
  240. {.$define EnableBackwardCompatibleMMSharing}
  241. {-----------------------Security Options------------------------}
  242. {Windows clears physical memory before reusing it in another process. However,
  243. it is not known how quickly this clearing is performed, so it is conceivable
  244. that confidential data may linger in physical memory longer than absolutely
  245. necessary. If you're paranoid about this kind of thing, enable this option to
  246. clear all freed memory before returning it to the operating system. Note that
  247. this incurs a noticeable performance hit.}
  248. {.$define ClearMemoryBeforeReturningToOS}
  249. {With this option enabled freed memory will immediately be cleared inside the
  250. FreeMem routine. This incurs a big performance hit, but may be worthwhile for
  251. additional peace of mind when working with highly sensitive data. This option
  252. supersedes the ClearMemoryBeforeReturningToOS option.}
  253. {.$define AlwaysClearFreedMemory}
  254. {--------------------------------Option Grouping------------------------------}
  255. {Enabling this option enables FullDebugMode, InstallOnlyIfRunningInIDE and
  256. LoadDebugDLLDynamically. Consequently, FastMM will install itself in
  257. FullDebugMode if the application is being debugged inside the Delphi IDE.
  258. Otherwise the default Delphi memory manager will be used (which is equivalent
  259. to the non-FullDebugMode FastMM since Delphi 2006.)}
  260. {.$define FullDebugModeInIDE}
  261. {Combines the FullDebugMode, LoadDebugDLLDynamically and
  262. DoNotInstallIfDLLMissing options. Consequently FastMM will only be installed
  263. (In FullDebugMode) when the FastMM_FullDebugMode.dll file is available. This
  264. is useful when the same executable will be distributed for both debugging as
  265. well as deployment.}
  266. {.$define FullDebugModeWhenDLLAvailable}
  267. {Group the options you use for release and debug versions below}
  268. {$undef Release}
  269. {$ifdef Release}
  270. {Specify the options you use for release versions below}
  271. {$undef FullDebugMode}
  272. {$undef CheckHeapForCorruption}
  273. {$define ASMVersion}
  274. {$undef EnableMemoryLeakReporting}
  275. {$undef UseOutputDebugString}
  276. {$else}
  277. {Specify the options you use for debugging below}
  278. {$define FullDebugMode}
  279. {$define EnableMemoryLeakReporting}
  280. {$define UseOutputDebugString}
  281. {$endif}
  282. {--------------------Compilation Options For borlndmm.dll---------------------}
  283. {If you're compiling the replacement borlndmm.dll, set the defines below
  284. for the kind of dll you require.}
  285. {Set this option when compiling the borlndmm.dll}
  286. {.$define borlndmmdll}
  287. {Set this option if the dll will be used by the Delphi IDE}
  288. {.$define dllforide}
  289. {Set this option if you're compiling a debug dll}
  290. {.$define debugdll}
  291. {Do not change anything below this line}
  292. {$ifdef borlndmmdll}
  293. {$define AssumeMultiThreaded}
  294. {$undef HideExpectedLeaksRegisteredByPointer}
  295. {$undef RequireDebuggerPresenceForLeakReporting}
  296. {$undef RequireDebugInfoForLeakReporting}
  297. {$define DetectMMOperationsAfterUninstall}
  298. {$undef ManualLeakReportingControl}
  299. {$undef ShareMM}
  300. {$undef AttemptToUseSharedMM}
  301. {$ifdef dllforide}
  302. {$define NeverUninstall}
  303. {$define HideMemoryLeakHintMessage}
  304. {$undef RequireIDEPresenceForLeakReporting}
  305. {$ifndef debugdll}
  306. {$undef EnableMemoryLeakReporting}
  307. {$endif}
  308. {$else}
  309. {$define EnableMemoryLeakReporting}
  310. {$undef NeverUninstall}
  311. {$undef HideMemoryLeakHintMessage}
  312. {$define RequireIDEPresenceForLeakReporting}
  313. {$endif}
  314. {$ifdef debugdll}
  315. {$define FullDebugMode}
  316. {$define RawStackTraces}
  317. {$undef CatchUseOfFreedInterfaces}
  318. {$define LogErrorsToFile}
  319. {$define LogMemoryLeakDetailToFile}
  320. {$undef ClearLogFileOnStartup}
  321. {$else}
  322. {$undef FullDebugMode}
  323. {$endif}
  324. {$endif}
  325. {Move BCB related definitions here, because CB2006/CB2007 can build borlndmm.dll
  326. for tracing memory leaks in BCB applications with "Build with Dynamic RTL"
  327. switched on}
  328. {------------------------------Patch BCB Terminate----------------------------}
  329. {To enable the patching for BCB to make uninstallation and leak reporting
  330. possible, you may need to add "BCB" definition
  331. in "Project Options->Pascal/Delphi Compiler->Defines".
  332. (Thanks to JiYuan Xie for implementing this.)}
  333. {$ifdef BCB}
  334. {$ifdef CheckHeapForCorruption}
  335. {$define PatchBCBTerminate}
  336. {$else}
  337. {$ifdef DetectMMOperationsAfterUninstall}
  338. {$define PatchBCBTerminate}
  339. {$else}
  340. {$ifdef EnableMemoryLeakReporting}
  341. {$define PatchBCBTerminate}
  342. {$endif}
  343. {$endif}
  344. {$endif}
  345. {$ifdef PatchBCBTerminate}
  346. {$define CheckCppObjectType}
  347. {$undef CheckCppObjectTypeEnabled}
  348. {$ifdef CheckCppObjectType}
  349. {$define CheckCppObjectTypeEnabled}
  350. {$endif}
  351. {Turn off "CheckCppObjectTypeEnabled" option if neither "CheckHeapForCorruption"
  352. option or "EnableMemoryLeakReporting" option were defined.}
  353. {$ifdef CheckHeapForCorruption}
  354. {$else}
  355. {$ifdef EnableMemoryLeakReporting}
  356. {$else}
  357. {$undef CheckCppObjectTypeEnabled}
  358. {$endif}
  359. {$endif}
  360. {$endif}
  361. {$endif}