source upload
This commit is contained in:
17369
contrib/mORMot/RTL7/FastMM4.pas
Normal file
17369
contrib/mORMot/RTL7/FastMM4.pas
Normal file
File diff suppressed because it is too large
Load Diff
158
contrib/mORMot/RTL7/FastMM4Messages.pas
Normal file
158
contrib/mORMot/RTL7/FastMM4Messages.pas
Normal file
@@ -0,0 +1,158 @@
|
||||
{
|
||||
|
||||
Fast Memory Manager: Messages
|
||||
|
||||
English translation by Pierre le Riche.
|
||||
|
||||
}
|
||||
|
||||
unit FastMM4Messages;
|
||||
|
||||
interface
|
||||
|
||||
{$Include FastMM4Options.inc}
|
||||
|
||||
const
|
||||
{The name of the debug info support DLL}
|
||||
{$IFDEF MACOS}
|
||||
FullDebugModeLibraryName32Bit = 'libFastMM_FullDebugMode.dylib';
|
||||
{$ELSE}
|
||||
FullDebugModeLibraryName32Bit = 'FastMM_FullDebugMode.dll';
|
||||
{$ENDIF}
|
||||
FullDebugModeLibraryName64Bit = 'FastMM_FullDebugMode64.dll';
|
||||
{Event log strings}
|
||||
LogFileExtension = '_MemoryManager_EventLog.txt'#0;
|
||||
CRLF = #13#10;
|
||||
EventSeparator = '--------------------------------';
|
||||
{Class name messages}
|
||||
UnknownClassNameMsg = 'Unknown';
|
||||
{Memory dump message}
|
||||
MemoryDumpMsg = #13#10#13#10'Current memory dump of 256 bytes starting at pointer address ';
|
||||
{Block Error Messages}
|
||||
BlockScanLogHeader = 'Allocated block logged by LogAllocatedBlocksToFile. The size is: ';
|
||||
ErrorMsgHeader = 'FastMM has detected an error during a ';
|
||||
GetMemMsg = 'GetMem';
|
||||
FreeMemMsg = 'FreeMem';
|
||||
ReallocMemMsg = 'ReallocMem';
|
||||
BlockCheckMsg = 'free block scan';
|
||||
OperationMsg = ' operation. ';
|
||||
BlockHeaderCorruptedMsg = 'The block header has been corrupted. ';
|
||||
BlockFooterCorruptedMsg = 'The block footer has been corrupted. ';
|
||||
FreeModifiedErrorMsg = 'FastMM detected that a block has been modified after being freed. ';
|
||||
FreeModifiedDetailMsg = #13#10#13#10'Modified byte offsets (and lengths): ';
|
||||
DoubleFreeErrorMsg = 'An attempt has been made to free/reallocate an unallocated block.';
|
||||
WrongMMFreeErrorMsg = 'An attempt has been made to free/reallocate a block that was allocated through a different FastMM instance. Check your memory manager sharing settings.';
|
||||
PreviousBlockSizeMsg = #13#10#13#10'The previous block size was: ';
|
||||
CurrentBlockSizeMsg = #13#10#13#10'The block size is: ';
|
||||
PreviousObjectClassMsg = #13#10#13#10'The block was previously used for an object of class: ';
|
||||
CurrentObjectClassMsg = #13#10#13#10'The block is currently used for an object of class: ';
|
||||
PreviousAllocationGroupMsg = #13#10#13#10'The allocation group was: ';
|
||||
PreviousAllocationNumberMsg = #13#10#13#10'The allocation number was: ';
|
||||
CurrentAllocationGroupMsg = #13#10#13#10'The allocation group is: ';
|
||||
CurrentAllocationNumberMsg = #13#10#13#10'The allocation number is: ';
|
||||
BlockErrorMsgTitle = 'Memory Error Detected';
|
||||
VirtualMethodErrorHeader = 'FastMM has detected an attempt to call a virtual method on a freed object. An access violation will now be raised in order to abort the current operation.';
|
||||
InterfaceErrorHeader = 'FastMM has detected an attempt to use an interface of a freed object. An access violation will now be raised in order to abort the current operation.';
|
||||
BlockHeaderCorruptedNoHistoryMsg = ' Unfortunately the block header has been corrupted so no history is available.';
|
||||
FreedObjectClassMsg = #13#10#13#10'Freed object class: ';
|
||||
VirtualMethodName = #13#10#13#10'Virtual method: ';
|
||||
VirtualMethodOffset = 'Offset +';
|
||||
VirtualMethodAddress = #13#10#13#10'Virtual method address: ';
|
||||
{Stack trace messages}
|
||||
CurrentThreadIDMsg = #13#10#13#10'The current thread ID is 0x';
|
||||
CurrentStackTraceMsg = ', and the stack trace (return addresses) leading to this error is:';
|
||||
ThreadIDPrevAllocMsg = #13#10#13#10'This block was previously allocated by thread 0x';
|
||||
ThreadIDAtAllocMsg = #13#10#13#10'This block was allocated by thread 0x';
|
||||
ThreadIDAtFreeMsg = #13#10#13#10'The block was previously freed by thread 0x';
|
||||
ThreadIDAtObjectAllocMsg = #13#10#13#10'The object was allocated by thread 0x';
|
||||
ThreadIDAtObjectFreeMsg = #13#10#13#10'The object was subsequently freed by thread 0x';
|
||||
StackTraceMsg = ', and the stack trace (return addresses) at the time was:';
|
||||
{Installation Messages}
|
||||
AlreadyInstalledMsg = 'FastMM4 is already installed.';
|
||||
AlreadyInstalledTitle = 'Already installed.';
|
||||
OtherMMInstalledMsg = 'FastMM4 cannot be installed since another third party memory '
|
||||
+ 'manager has already installed itself.'#13#10'If you want to use FastMM4, '
|
||||
+ 'please make sure that FastMM4.pas is the very first unit in the "uses"'
|
||||
+ #13#10'section of your project''s .dpr file.';
|
||||
OtherMMInstalledTitle = 'Cannot install FastMM4 - Another memory manager is already installed';
|
||||
MemoryAllocatedMsg = 'FastMM4 cannot install since memory has already been '
|
||||
+ 'allocated through the default memory manager.'#13#10'FastMM4.pas MUST '
|
||||
+ 'be the first unit in your project''s .dpr file, otherwise memory may '
|
||||
+ 'be allocated'#13#10'through the default memory manager before FastMM4 '
|
||||
+ 'gains control. '#13#10#13#10'If you are using an exception trapper '
|
||||
+ 'like MadExcept (or any tool that modifies the unit initialization '
|
||||
+ 'order),'#13#10'go into its configuration page and ensure that the '
|
||||
+ 'FastMM4.pas unit is initialized before any other unit.';
|
||||
MemoryAllocatedTitle = 'Cannot install FastMM4 - Memory has already been allocated';
|
||||
{Leak checking messages}
|
||||
LeakLogHeader = 'A memory block has been leaked. The size is: ';
|
||||
LeakMessageHeader = 'This application has leaked memory. ';
|
||||
SmallLeakDetail = 'The small block leaks are'
|
||||
{$ifdef HideExpectedLeaksRegisteredByPointer}
|
||||
+ ' (excluding expected leaks registered by pointer)'
|
||||
{$endif}
|
||||
+ ':'#13#10;
|
||||
LargeLeakDetail = 'The sizes of leaked medium and large blocks are'
|
||||
{$ifdef HideExpectedLeaksRegisteredByPointer}
|
||||
+ ' (excluding expected leaks registered by pointer)'
|
||||
{$endif}
|
||||
+ ': ';
|
||||
BytesMessage = ' bytes: ';
|
||||
AnsiStringBlockMessage = 'AnsiString';
|
||||
UnicodeStringBlockMessage = 'UnicodeString';
|
||||
LeakMessageFooter = #13#10
|
||||
{$ifndef HideMemoryLeakHintMessage}
|
||||
+ #13#10'Note: '
|
||||
{$ifdef RequireIDEPresenceForLeakReporting}
|
||||
+ 'This memory leak check is only performed if Delphi is currently running on the same computer. '
|
||||
{$endif}
|
||||
{$ifdef FullDebugMode}
|
||||
{$ifdef LogMemoryLeakDetailToFile}
|
||||
+ 'Memory leak detail is logged to a text file in the same folder as this application. '
|
||||
{$else}
|
||||
+ 'Enable the "LogMemoryLeakDetailToFile" to obtain a log file containing detail on memory leaks. '
|
||||
{$endif}
|
||||
{$else}
|
||||
+ 'To obtain a log file containing detail on memory leaks, enable the "FullDebugMode" and "LogMemoryLeakDetailToFile" conditional defines. '
|
||||
{$endif}
|
||||
+ 'To disable this memory leak check, undefine "EnableMemoryLeakReporting".'#13#10
|
||||
{$endif}
|
||||
+ #0;
|
||||
LeakMessageTitle = 'Memory Leak Detected';
|
||||
{$ifdef UseOutputDebugString}
|
||||
FastMMInstallMsg = 'FastMM has been installed.';
|
||||
FastMMInstallSharedMsg = 'Sharing an existing instance of FastMM.';
|
||||
FastMMUninstallMsg = 'FastMM has been uninstalled.';
|
||||
FastMMUninstallSharedMsg = 'Stopped sharing an existing instance of FastMM.';
|
||||
{$endif}
|
||||
{$ifdef DetectMMOperationsAfterUninstall}
|
||||
InvalidOperationTitle = 'MM Operation after uninstall.';
|
||||
InvalidGetMemMsg = 'FastMM has detected a GetMem call after FastMM was uninstalled.';
|
||||
InvalidFreeMemMsg = 'FastMM has detected a FreeMem call after FastMM was uninstalled.';
|
||||
InvalidReallocMemMsg = 'FastMM has detected a ReallocMem call after FastMM was uninstalled.';
|
||||
InvalidAllocMemMsg = 'FastMM has detected an AllocMem call after FastMM was uninstalled.';
|
||||
{$endif}
|
||||
|
||||
{$ifdef LogLockContention}
|
||||
LockingReportTitle = 'Locking Report';
|
||||
LockingReportHeader = 'Top locking contention sites';
|
||||
{$endif}
|
||||
|
||||
{$ifdef UseReleaseStack}
|
||||
{$ifdef DebugReleaseStack}
|
||||
ReleaseStackUsageHeader = 'Release stack usage statistics';
|
||||
ReleaseStackUsageSmallBlocksMsg1 = 'Small blocks [';
|
||||
ReleaseStackUsageSmallBlocksMsg2 = ']: ';
|
||||
ReleaseStackUsageTotalSmallBlocksMsg = 'Total small blocks: ';
|
||||
ReleaseStackUsageMediumBlocksMsg = 'Medium blocks: ';
|
||||
ReleaseStackUsageLargeBlocksMsg = 'Large blocks: ';
|
||||
ReleaseStackUsageTotalMemoryMsg = 'Total memory: ';
|
||||
ReleaseStackUsageBuffers1Msg = ' in ';
|
||||
ReleaseStackUsageBuffers2Msg = ' buffers [';
|
||||
{$endif}
|
||||
{$endif}
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
606
contrib/mORMot/RTL7/FastMM4Options.inc
Normal file
606
contrib/mORMot/RTL7/FastMM4Options.inc
Normal file
@@ -0,0 +1,606 @@
|
||||
{
|
||||
|
||||
Fast Memory Manager: Options Include File
|
||||
|
||||
Set the default options for FastMM here.
|
||||
|
||||
}
|
||||
|
||||
{---------------------------Miscellaneous Options-----------------------------}
|
||||
|
||||
{Enable Align16Bytes define to align all blocks on 16 byte boundaries,
|
||||
or enable Align32Bytes define to align all blocks on 32 byte boundaries,
|
||||
so aligned SSE instructions can be used safely.
|
||||
|
||||
If neither of these options are enabled, then some of the
|
||||
smallest block sizes will be 8-byte aligned instead which may result in a
|
||||
reduction in memory usage.
|
||||
|
||||
Even when small blocks are aligned by 8 bytes
|
||||
(no Align16Bytes or Align32Bytes are defined),
|
||||
Medium and large blocks are always 16-byte aligned.
|
||||
|
||||
If you enable AVX, then the alignment will always be 32 bytes.}
|
||||
|
||||
|
||||
{.$define Align16Bytes}
|
||||
{.$define Align32Bytes}
|
||||
|
||||
|
||||
{Enable to use faster fixed-size move routines when upsizing small blocks.
|
||||
These routines are much faster than the Borland RTL move procedure since they
|
||||
are optimized to move a fixed number of bytes. This option may be used
|
||||
together with the FastMove library for even better performance.}
|
||||
{$define UseCustomFixedSizeMoveRoutines}
|
||||
|
||||
{Enable this option to use an optimized procedure for moving a memory block of
|
||||
an arbitrary size. Disable this option when using the Fastcode move
|
||||
("FastMove") library. Using the Fastcode move library allows your whole
|
||||
application to gain from faster move routines, not just the memory manager. It
|
||||
is thus recommended that you use the Fastcode move library in conjunction with
|
||||
this memory manager and disable this option.}
|
||||
{$define UseCustomVariableSizeMoveRoutines}
|
||||
|
||||
{Enable this option to only install FastMM as the memory manager when the
|
||||
application is running inside the Delphi IDE. This is useful when you want
|
||||
to deploy the same EXE that you use for testing, but only want the debugging
|
||||
features active on development machines. When this option is enabled and
|
||||
the application is not being run inside the IDE debugger, then the default
|
||||
Delphi memory manager will be used (which, since Delphi 2006, is FastMM
|
||||
without FullDebugMode.}
|
||||
{.$define InstallOnlyIfRunningInIDE}
|
||||
|
||||
{Due to QC#14070 ("Delphi IDE attempts to free memory after the shutdown code
|
||||
of borlndmm.dll has been called"), FastMM cannot be uninstalled safely when
|
||||
used inside a replacement borlndmm.dll for the IDE. Setting this option will
|
||||
circumvent this problem by never uninstalling the memory manager.}
|
||||
{.$define NeverUninstall}
|
||||
|
||||
{Set this option when you use runtime packages in this application or library.
|
||||
This will automatically set the "AssumeMultiThreaded" option. Note that you
|
||||
have to ensure that FastMM is finalized after all live pointers have been
|
||||
freed - failure to do so will result in a large leak report followed by a lot
|
||||
of A/Vs. (See the FAQ for more detail.) You may have to combine this option
|
||||
with the NeverUninstall option.}
|
||||
{.$define UseRuntimePackages}
|
||||
|
||||
{-----------------------Concurrency Management Options------------------------}
|
||||
|
||||
{Enable to always assume that the application is multithreaded. Enabling this
|
||||
option will cause a significant performance hit with single threaded
|
||||
applications. Enable if you are using multi-threaded third-party tools that do
|
||||
not properly set the IsMultiThread variable. Also set this option if you are
|
||||
going to share this memory manager between a single threaded application and a
|
||||
multi-threaded DLL.}
|
||||
{.$define AssumeMultiThreaded}
|
||||
|
||||
{Enable this option to not call Sleep when a thread contention occurs. This
|
||||
option will improve performance if the ratio of the number of active threads
|
||||
to the number of CPU cores is low (typically < 2). With this option set a
|
||||
thread will usually enter a "busy waiting" loop instead of relinquishing its
|
||||
timeslice when a thread contention occurs, unless UseSwitchToThread is
|
||||
also defined (see below) in which case it will call SwitchToThread instead of
|
||||
Sleep.
|
||||
|
||||
*** Note: This option was added in FastMM 4 version Version 4.68
|
||||
on 3 July 2006, is provided only if you wish to restore old
|
||||
functionality (e.g. for testing, etc.), and is not recommended
|
||||
for FastMM4-AVX, since this it provides suboptimal performance compare
|
||||
to the new locking mechanism implemented in the FastMM4-AVX.
|
||||
This option has no effect when SmallBlocksLockedCriticalSection/
|
||||
MediumBlocksLockedCriticalSection/LargeBlocksLockedCriticalSection is enabled}
|
||||
|
||||
{.$define NeverSleepOnThreadContention}
|
||||
|
||||
{Set this option to call SwitchToThread instead of sitting in a "busy waiting"
|
||||
loop when a thread contention occurs. This is used in conjunction with the
|
||||
NeverSleepOnThreadContention option, and has no effect unless
|
||||
NeverSleepOnThreadContention is also defined. This option may improve
|
||||
performance with many CPU cores and/or threads of different priorities. Note
|
||||
that the SwitchToThread API call is only available on Windows 2000 and later,
|
||||
but FastMM4 loads it dynamically, so it would not fail even under very old
|
||||
versions of Windows.
|
||||
|
||||
*** Note: This option was added in FastMM 4 version Version 4.97
|
||||
on 30 September 2010, is provided only if you wish to restore old
|
||||
functionality (e.g. for testing, etc.), and is not recommended
|
||||
for FastMM4-AVX, since this it provides suboptimal performance compare
|
||||
to the new locking mechanism implemented in the FastMM4-AVX.
|
||||
This option has no effect when SmallBlocksLockedCriticalSection/
|
||||
MediumBlocksLockedCriticalSection/LargeBlocksLockedCriticalSection is enabled}
|
||||
|
||||
{.$define UseSwitchToThread}
|
||||
|
||||
{This option uses a simpler instruction to acquire a lock: "lock xchg",
|
||||
instead of "lock cmpxchg" used in earlier versions of FastMM4: there is
|
||||
actually no reason to use "cmpxchg", because the simple instruction - "xchg" -
|
||||
perfectly suits our need. Although "xchg" has exactly the same latency and
|
||||
costs in terms of CPU cycles as "cmpxghg", it is just simper way to do the
|
||||
lock that we need, and, according to the Occam's razor principle, simple things
|
||||
are better. If you wish to restore old functionality of FastMM4 version 4.992,
|
||||
disable this option }
|
||||
{$define SimplifiedInterlockedExchangeByte}
|
||||
|
||||
{These 3 options make FastMM4-AVX to use a new approach to waiting for a lock:
|
||||
CriticalSections instead of Sleep(). With these options, the Sleep() will
|
||||
never be used but EnterCriticalSection/LeaveCriticalSection will be
|
||||
used instead. Testing has shown that the approach of using CriticalSections
|
||||
instead of Sleep (which was used by default before in FastMM4) provides
|
||||
significant gain in situations when the number of threads working with the
|
||||
memory manager is the same or higher than the number of physical cores.
|
||||
This options take away the original FastMM4 approach of using
|
||||
Sleep(InitialSleepTime) and then Sleep(AdditionalSleepTime)
|
||||
(or Sleep(0) and Sleep(1)) and replace them with
|
||||
EnterCriticalSection/LeaveCriticalSection to save valuable CPU cycles wasted by
|
||||
Sleep(0) and to improve speed (reduce latency) that was affected each time by
|
||||
at least 1 millisecond by Sleep(1), because the Critical Sections are much more
|
||||
CPU-friendly and have definitely lower latency than Sleep(1).
|
||||
|
||||
When these options are enabled, FastMM4-AVX it checks:
|
||||
- whether the CPU supports SSE2 and thus the "pause" instruction, and
|
||||
- whether the operating system has the SwitchToThread() API call, and,
|
||||
and in this case uses "pause" spin-loop for 5000 iterations and then
|
||||
SwitchToThread() instead of critical sections; If a CPU doesn't have the
|
||||
"pause" instrcution or Windows doesn't have the SwitchToThread() API
|
||||
function, it will use EnterCriticalSection/LeaveCriticalSection.
|
||||
When FastMM4-AVX uses "pause" and SwitchToThread(), tests that allocate,
|
||||
reallocate and release memory finish up to two times faster when the
|
||||
number of threads is the same or greater than the number of physical cores}
|
||||
|
||||
{$define SmallBlocksLockedCriticalSection}
|
||||
{$define MediumBlocksLockedCriticalSection}
|
||||
{$define LargeBlocksLockedCriticalSection}
|
||||
|
||||
{$define CheckPauseAndSwitchToThreadForAsmVersion}
|
||||
|
||||
|
||||
{-----------------------------Debugging Options-------------------------------}
|
||||
|
||||
{Enable this option to suppress the generation of debug info for the
|
||||
FastMM4.pas unit. This will prevent the integrated debugger from stepping into
|
||||
the memory manager code.}
|
||||
{$define NoDebugInfo}
|
||||
|
||||
{Enable this option to suppress the display of all message dialogs. This is
|
||||
useful in service applications that should not be interrupted.}
|
||||
{.$define NoMessageBoxes}
|
||||
|
||||
{Set this option to use the Windows API OutputDebugString procedure to output
|
||||
debug strings on startup/shutdown and when errors occur.}
|
||||
{.$define UseOutputDebugString}
|
||||
|
||||
{Set this option to use the assembly language version which is faster than the
|
||||
pascal version. Disable only for debugging purposes. Setting the
|
||||
CheckHeapForCorruption option automatically disables this option.}
|
||||
{$define ASMVersion}
|
||||
|
||||
{Allow using ".align" assembler directive. FreePascal doesn't support ".align"
|
||||
Delphi incorrectly encodes conditional jumps (used 6-byte instructions instead
|
||||
of just 2 bytes. So don't use it for Borland (Embarcadero) Delphi neither
|
||||
for FreePascal}
|
||||
{.$define EnableAsmCodeAlign}
|
||||
|
||||
{FastMM always catches attempts to free the same memory block twice, however it
|
||||
can also check for corruption of the memory heap (typically due to the user
|
||||
program overwriting the bounds of allocated memory). These checks are
|
||||
expensive, and this option should thus only be used for debugging purposes.
|
||||
If this option is set then the ASMVersion option is automatically disabled.}
|
||||
{.$define CheckHeapForCorruption}
|
||||
|
||||
{Enable this option to catch attempts to perform MM operations after FastMM has
|
||||
been uninstalled. With this option set when FastMM is uninstalled it will not
|
||||
install the previous MM, but instead a dummy MM handler that throws an error
|
||||
if any MM operation is attempted. This will catch attempts to use the MM
|
||||
after FastMM has been uninstalled.}
|
||||
{$define DetectMMOperationsAfterUninstall}
|
||||
|
||||
{Set the following option to do extensive checking of all memory blocks. All
|
||||
blocks are padded with both a header and trailer that are used to verify the
|
||||
integrity of the heap. Freed blocks are also cleared to ensure that they
|
||||
cannot be reused after being freed. This option slows down memory operations
|
||||
dramatically and should only be used to debug an application that is
|
||||
overwriting memory or reusing freed pointers. Setting this option
|
||||
automatically enables CheckHeapForCorruption and disables ASMVersion.
|
||||
Very important: If you enable this option your application will require the
|
||||
FastMM_FullDebugMode.dll library. If this library is not available you will
|
||||
get an error on startup.}
|
||||
{.$define FullDebugMode}
|
||||
|
||||
{Set this option to perform "raw" stack traces, i.e. check all entries on the
|
||||
stack for valid return addresses. Note that this is significantly slower
|
||||
than using the stack frame tracing method, but is usually more complete. Has
|
||||
no effect unless FullDebugMode is enabled}
|
||||
{$define RawStackTraces}
|
||||
|
||||
{Set this option to check for user code that uses an interface of a freed
|
||||
object. Note that this will disable the checking of blocks modified after
|
||||
being freed (the two are not compatible). This option has no effect if
|
||||
FullDebugMode is not also enabled.}
|
||||
{.$define CatchUseOfFreedInterfaces}
|
||||
|
||||
{Set this option to log all errors to a text file in the same folder as the
|
||||
application. Memory errors (with the FullDebugMode option set) will be
|
||||
appended to the log file. Has no effect if "FullDebugMode" is not set.}
|
||||
{$define LogErrorsToFile}
|
||||
|
||||
{Set this option to log all memory leaks to a text file in the same folder as
|
||||
the application. Memory leak reports (with the FullDebugMode option set)
|
||||
will be appended to the log file. Has no effect if "LogErrorsToFile" and
|
||||
"FullDebugMode" are not also set. Note that usually all leaks are always
|
||||
logged, even if they are "expected" leaks registered through
|
||||
AddExpectedMemoryLeaks. Expected leaks registered by pointer may be excluded
|
||||
through the HideExpectedLeaksRegisteredByPointer option.}
|
||||
{$define LogMemoryLeakDetailToFile}
|
||||
|
||||
{Deletes the error log file on startup. No effect if LogErrorsToFile is not
|
||||
also set.}
|
||||
{.$define ClearLogFileOnStartup}
|
||||
|
||||
{Loads the FASTMM_FullDebugMode.dll dynamically. If the DLL cannot be found
|
||||
then stack traces will not be available. Note that this may cause problems
|
||||
due to a changed DLL unload order when sharing the memory manager. Use with
|
||||
care.}
|
||||
{.$define LoadDebugDLLDynamically}
|
||||
|
||||
{.$define DoNotInstallIfDLLMissing}
|
||||
{If the FastMM_FullDebugMode.dll file is not available then FastMM will not
|
||||
install itself. No effect unless FullDebugMode and LoadDebugDLLDynamically
|
||||
are also defined.}
|
||||
|
||||
{.$define RestrictDebugDLLLoadPath}
|
||||
{Allow to load debug dll only from host module directory.}
|
||||
|
||||
{FastMM usually allocates large blocks from the topmost available address and
|
||||
medium and small blocks from the lowest available address (This reduces
|
||||
fragmentation somewhat). With this option set all blocks are always
|
||||
allocated from the highest available address. If the process has a >2GB
|
||||
address space and contains bad pointer arithmetic code, this option should
|
||||
help to catch those errors sooner.}
|
||||
{$define AlwaysAllocateTopDown}
|
||||
|
||||
{Disables the logging of memory dumps together with the other detail for
|
||||
memory errors.}
|
||||
{.$define DisableLoggingOfMemoryDumps}
|
||||
|
||||
{If FastMM encounters a problem with a memory block inside the FullDebugMode
|
||||
FreeMem handler then an "invalid pointer operation" exception will usually
|
||||
be raised. If the FreeMem occurs while another exception is being handled
|
||||
(perhaps in the try.. finally code) then the original exception will be
|
||||
lost. With this option set FastMM will ignore errors inside FreeMem when an
|
||||
exception is being handled, thus allowing the original exception to
|
||||
propagate.}
|
||||
{$define SuppressFreeMemErrorsInsideException}
|
||||
|
||||
{Adds support for notification of memory manager events in FullDebugMode.
|
||||
With this define set, the application may assign the OnDebugGetMemFinish,
|
||||
OnDebugFreeMemStart, etc. callbacks in order to be notified when the
|
||||
particular memory manager event occurs.}
|
||||
{.$define FullDebugModeCallBacks}
|
||||
|
||||
{---------------------------Memory Leak Reporting-----------------------------}
|
||||
|
||||
{Set the option EnableMemoryLeakReporting to enable reporting of memory leaks.
|
||||
Combine it with the two options below for further fine-tuning.}
|
||||
|
||||
{$ifndef DisableMemoryLeakReporting}
|
||||
{.$define EnableMemoryLeakReporting}
|
||||
{$endif}
|
||||
|
||||
{Set this option to suppress the display and logging of expected memory leaks
|
||||
that were registered by pointer. Leaks registered by size or class are often
|
||||
ambiguous, so these expected leaks are always logged to file (in
|
||||
FullDebugMode with the LogMemoryLeakDetailToFile option set) and are never
|
||||
hidden from the leak display if there are more leaks than are expected.}
|
||||
{$define HideExpectedLeaksRegisteredByPointer}
|
||||
|
||||
{Set this option to require the presence of the Delphi IDE to report memory
|
||||
leaks. This option has no effect if the option "EnableMemoryLeakReporting"
|
||||
is not also set.}
|
||||
{.$define RequireIDEPresenceForLeakReporting}
|
||||
|
||||
{Set this option to require the program to be run inside the IDE debugger to
|
||||
report memory leaks. This option has no effect if the option
|
||||
"EnableMemoryLeakReporting" is not also set. Note that this option does not
|
||||
work with libraries, only EXE projects.}
|
||||
{$define RequireDebuggerPresenceForLeakReporting}
|
||||
|
||||
{Set this option to require the presence of debug info ($D+ option) in the
|
||||
compiled unit to perform memory leak checking. This option has no effect if
|
||||
the option "EnableMemoryLeakReporting" is not also set.}
|
||||
{.$define RequireDebugInfoForLeakReporting}
|
||||
|
||||
{Set this option to enable manual control of the memory leak report. When
|
||||
this option is set the ReportMemoryLeaksOnShutdown variable (default = false)
|
||||
may be changed to select whether leak reporting should be done or not. When
|
||||
this option is selected then both the variable must be set to true and the
|
||||
other leak checking options must be applicable for the leak checking to be
|
||||
done.}
|
||||
{.$define ManualLeakReportingControl}
|
||||
|
||||
{Set this option to disable the display of the hint below the memory leak
|
||||
message.}
|
||||
{.$define HideMemoryLeakHintMessage}
|
||||
|
||||
{Set this option to use QualifiedClassName equivalent instead of ClassName
|
||||
equivalent during memory leak reporting.
|
||||
This is useful for duplicate class names (like EConversionError, which is in
|
||||
units Data.DBXJSONReflect, REST.JsonReflect and System.ConvUtils,
|
||||
or TClipboard being in Vcl.Clibprd and WinAPI.ApplicationModel.DataTransfer }
|
||||
{$define EnableMemoryLeakReportingUsesQualifiedClassName}
|
||||
|
||||
{--------------------------Instruction Set Options----------------------------}
|
||||
|
||||
{Set this option to enable the use of MMX instructions. Disabling this option
|
||||
will result in a slight performance hit, but will enable compatibility with
|
||||
AMD K5, Pentium I and earlier CPUs. MMX is currently only used in the variable
|
||||
size move routines, so if UseCustomVariableSizeMoveRoutines is not set then
|
||||
this option has no effect.}
|
||||
{.$define EnableMMX}
|
||||
|
||||
{$ifndef DontForceMMX}
|
||||
|
||||
{Set this option (ForceMMX) to force the use of MMX instructions without checking
|
||||
whether the CPU supports it. If this option is disabled then the CPU will be
|
||||
checked for compatibility first, and if MMX is not supported it will fall
|
||||
back to the FPU move code. Has no effect unless EnableMMX is also set.}
|
||||
{$define ForceMMX}
|
||||
|
||||
{$endif}
|
||||
|
||||
|
||||
{$ifndef DisableAVX}
|
||||
|
||||
{Set this option (EnableAVX) to enable use of AVX instructions under 64-bit mode.
|
||||
This option has no effect under 32-bit mode. If enalbed, the code will check
|
||||
whether the CPU supports AVX or AVX2, and, if yes, will use the 32-byte YMM
|
||||
registers for faster memory copy. Besides that, if this option is enabled,
|
||||
all allocated memory blocks will be aligned by 32 bytes, that will incur
|
||||
addition memory consumption overhead. Besides that, with this option, memory
|
||||
copy will be slightly more secure, because all XMM/YMM registers used to copy
|
||||
memory will be cleared by vxorps/vpxor at the end of a copy routine, so the
|
||||
leftovers of the copied memory data will not be kept in the XMM/YMM registers
|
||||
and will not be exposed. This option properly handles AVX-SSE transitions to not
|
||||
incur the transition penalties, only calls vzeroupper under AVX1, but not under
|
||||
AVX2, since it slows down subsequent SSE code under Kaby Lake}
|
||||
{$define EnableAVX}
|
||||
|
||||
{$endif}
|
||||
|
||||
{$ifdef EnableAVX}
|
||||
{If AVX is enabled, you can optionally disable one or more
|
||||
of the following AVX modes:
|
||||
- the first version - initial AVX (DisableAVX1); or
|
||||
- the second version AVX2 (DisableAVX2); or
|
||||
- AVX-512 (DisableAVX512);
|
||||
but you cannot disable all of the above modes at once.
|
||||
|
||||
If you define DisableAVX1, it will not add to FastMM4 the instructions from
|
||||
the initial (first) version of the Advanced Vector Extensions instruction set,
|
||||
officially called just "AVX", proposed by Intel in March 2008 and first
|
||||
supported by Intel with the Sandy Bridge processor shipping in Q1 2011
|
||||
and later, on by AMD with the Bulldozer processor shipping in Q3 2011.
|
||||
|
||||
If you define DisableAVX2, it will not add to FastMM4 the instructions from
|
||||
the second version of the Advanced Vector Extensions - officially called
|
||||
"AVX2", also known as Haswell New Instructions, which is an expansion of the
|
||||
AVX instruction set introduced in Intel's Haswell microarchitecture.
|
||||
Intel has shipped first processors with AVX2 on June 2, 2013: Core i7 4770,
|
||||
Core i5 4670, etc., and AMD has shipped first processors with AVX in Q2 2015
|
||||
(Carrizo processor). AMD Ryzen processor (Q1 2017) also supports AVX2.
|
||||
We use separate code for AVX1 and AVX2 because AVX2 doesn't use "vzeroupper"
|
||||
and uses the new, faster instruction "vpxor" which was not available in the
|
||||
initial AVX, which, in its turn, uses "vxorps" and "vzeroupper" before and
|
||||
after any AVX code to counteract the AVX-SSE transition penalties.
|
||||
FastMM4 checks whether AVX2 is supported by the CPU, and, if supported, never
|
||||
calls AVX1 functions, since calling "vzeroupper" even once in a thread
|
||||
significantly slows down all subsequent SSE code, which is not documented:
|
||||
neither in the Intel 64 and IA-32 Architectures Software Developer<65>s Manual
|
||||
nor in the Intel 64 and IA-32 Architectures Optimization Reference Manual.
|
||||
|
||||
The code of AVX1 is grouped separately from the code of AVX2, to not scatter
|
||||
the cache}
|
||||
|
||||
|
||||
{.$define DisableAVX1}
|
||||
{.$define DisableAVX2}
|
||||
{.$define DisableAVX512}
|
||||
{$endif}
|
||||
|
||||
|
||||
{$ifndef DisableERMS}
|
||||
|
||||
{Set this option (EnableERMS) to enable Enhanced Rep Movsb/Stosb CPU feature,
|
||||
which improves speed of medium and large block memory copy
|
||||
under 32-bit or 64-bit modes}
|
||||
{$define EnableERMS}
|
||||
|
||||
{$endif}
|
||||
|
||||
|
||||
{-----------------------Memory Manager Sharing Options------------------------}
|
||||
|
||||
{Allow sharing of the memory manager between a main application and DLLs that
|
||||
were also compiled with FastMM. This allows you to pass dynamic arrays and
|
||||
long strings to DLL functions provided both are compiled to use FastMM.
|
||||
Sharing will only work if the library that is supposed to share the memory
|
||||
manager was compiled with the "AttemptToUseSharedMM" option set. Note that if
|
||||
the main application is single threaded and the DLL is multi-threaded that you
|
||||
have to set the IsMultiThread variable in the main application to true or it
|
||||
will crash when a thread contention occurs. Note that statically linked DLL
|
||||
files are initialized before the main application, so the main application may
|
||||
well end up sharing a statically loaded DLL's memory manager and not the other
|
||||
way around. }
|
||||
{.$define ShareMM}
|
||||
|
||||
{Allow sharing of the memory manager by a DLL with other DLLs (or the main
|
||||
application if this is a statically loaded DLL) that were also compiled with
|
||||
FastMM. Set this option with care in dynamically loaded DLLs, because if the
|
||||
DLL that is sharing its MM is unloaded and any other DLL is still sharing
|
||||
the MM then the application will crash. This setting is only relevant for
|
||||
DLL libraries and requires ShareMM to also be set to have any effect.
|
||||
Sharing will only work if the library that is supposed to share the memory
|
||||
manager was compiled with the "AttemptToUseSharedMM" option set. Note that
|
||||
if DLLs are statically linked then they will be initialized before the main
|
||||
application and then the DLL will in fact share its MM with the main
|
||||
application. This option has no effect unless ShareMM is also set.}
|
||||
{.$define ShareMMIfLibrary}
|
||||
|
||||
{Define this to attempt to share the MM of the main application or other loaded
|
||||
DLLs in the same process that were compiled with ShareMM set. When sharing a
|
||||
memory manager, memory leaks caused by the sharer will not be freed
|
||||
automatically. Take into account that statically linked DLLs are initialized
|
||||
before the main application, so set the sharing options accordingly.}
|
||||
{.$define AttemptToUseSharedMM}
|
||||
|
||||
{Define this to enable backward compatibility for the memory manager sharing
|
||||
mechanism used by Delphi 2006 and 2007, as well as older FastMM versions.}
|
||||
{$define EnableBackwardCompatibleMMSharing}
|
||||
|
||||
{-----------------------Security Options------------------------}
|
||||
|
||||
{Windows clears physical memory before reusing it in another process. However,
|
||||
it is not known how quickly this clearing is performed, so it is conceivable
|
||||
that confidential data may linger in physical memory longer than absolutely
|
||||
necessary. If you're paranoid about this kind of thing, enable this option to
|
||||
clear all freed memory before returning it to the operating system. Note that
|
||||
this incurs a noticeable performance hit.}
|
||||
{.$define ClearMemoryBeforeReturningToOS}
|
||||
|
||||
{With this option enabled freed memory will immediately be cleared inside the
|
||||
FreeMem routine. This incurs a big performance hit, but may be worthwhile for
|
||||
additional peace of mind when working with highly sensitive data. This option
|
||||
supersedes the ClearMemoryBeforeReturningToOS option.}
|
||||
{.$define AlwaysClearFreedMemory}
|
||||
|
||||
{----------------------------Lock Contention Logging--------------------------}
|
||||
|
||||
{Define this to lock stack traces for all occasions where GetMem/FreeMem
|
||||
go to sleep because of lock contention (IOW, when memory manager is already
|
||||
locked by another thread). At the end of the program execution top 10 sites
|
||||
(locations with highest occurrence) will be logged to the _MemoryManager_EventLog.txt
|
||||
file.
|
||||
This options works with FullDebugMode or without it, but requires
|
||||
FastMM_FullDebugMode.dll to be present in both cases.
|
||||
}
|
||||
{.$define LogLockContention}
|
||||
|
||||
{--------------------------------Option Grouping------------------------------}
|
||||
|
||||
{Enabling this option enables FullDebugMode, InstallOnlyIfRunningInIDE and
|
||||
LoadDebugDLLDynamically. Consequently, FastMM will install itself in
|
||||
FullDebugMode if the application is being debugged inside the Delphi IDE.
|
||||
Otherwise the default Delphi memory manager will be used (which is equivalent
|
||||
to the non-FullDebugMode FastMM since Delphi 2006.)}
|
||||
{.$define FullDebugModeInIDE}
|
||||
|
||||
{Combines the FullDebugMode, LoadDebugDLLDynamically and
|
||||
DoNotInstallIfDLLMissing options. Consequently FastMM will only be installed
|
||||
(In FullDebugMode) when the FastMM_FullDebugMode.dll file is available. This
|
||||
is useful when the same executable will be distributed for both debugging as
|
||||
well as deployment.}
|
||||
{.$define FullDebugModeWhenDLLAvailable}
|
||||
|
||||
{Group the options you use for release and debug versions below}
|
||||
{$ifdef Release}
|
||||
{Specify the options you use for release versions below}
|
||||
{.$undef FullDebugMode}
|
||||
{.$undef CheckHeapForCorruption}
|
||||
{.$define ASMVersion}
|
||||
{.$undef EnableMemoryLeakReporting}
|
||||
{.$undef UseOutputDebugString}
|
||||
{$else}
|
||||
{Specify the options you use for debugging below}
|
||||
{.$define FullDebugMode}
|
||||
{.$define EnableMemoryLeakReporting}
|
||||
{.$define UseOutputDebugString}
|
||||
{$endif}
|
||||
|
||||
{--------------------Compilation Options For borlndmm.dll---------------------}
|
||||
{If you're compiling the replacement borlndmm.dll, set the defines below
|
||||
for the kind of dll you require.}
|
||||
|
||||
{Set this option when compiling the borlndmm.dll}
|
||||
{.$define borlndmmdll}
|
||||
|
||||
{Set this option if the dll will be used by the Delphi IDE}
|
||||
{.$define dllforide}
|
||||
|
||||
{Set this option if you're compiling a debug dll}
|
||||
{.$define debugdll}
|
||||
|
||||
{Do not change anything below this line}
|
||||
{$ifdef borlndmmdll}
|
||||
{$define AssumeMultiThreaded}
|
||||
{$undef HideExpectedLeaksRegisteredByPointer}
|
||||
{$undef RequireDebuggerPresenceForLeakReporting}
|
||||
{$undef RequireDebugInfoForLeakReporting}
|
||||
{$define DetectMMOperationsAfterUninstall}
|
||||
{$undef ManualLeakReportingControl}
|
||||
{$undef ShareMM}
|
||||
{$undef AttemptToUseSharedMM}
|
||||
{$ifdef dllforide}
|
||||
{$define NeverUninstall}
|
||||
{$define HideMemoryLeakHintMessage}
|
||||
{$undef RequireIDEPresenceForLeakReporting}
|
||||
{$ifndef debugdll}
|
||||
{$undef EnableMemoryLeakReporting}
|
||||
{$endif}
|
||||
{$else}
|
||||
{$define EnableMemoryLeakReporting}
|
||||
{$undef NeverUninstall}
|
||||
{$undef HideMemoryLeakHintMessage}
|
||||
{$define RequireIDEPresenceForLeakReporting}
|
||||
{$endif}
|
||||
{$ifdef debugdll}
|
||||
{$define FullDebugMode}
|
||||
{$define RawStackTraces}
|
||||
{$undef CatchUseOfFreedInterfaces}
|
||||
{$define LogErrorsToFile}
|
||||
{$define LogMemoryLeakDetailToFile}
|
||||
{$undef ClearLogFileOnStartup}
|
||||
{$else}
|
||||
{$undef FullDebugMode}
|
||||
{$endif}
|
||||
{$endif}
|
||||
|
||||
{Move BCB related definitions here, because CB2006/CB2007 can build borlndmm.dll
|
||||
for tracing memory leaks in BCB applications with "Build with Dynamic RTL"
|
||||
switched on}
|
||||
{------------------------------Patch BCB Terminate----------------------------}
|
||||
{To enable the patching for BCB to make uninstallation and leak reporting
|
||||
possible, you may need to add "BCB" definition
|
||||
in "Project Options->Pascal/Delphi Compiler->Defines".
|
||||
(Thanks to JiYuan Xie for implementing this.)}
|
||||
|
||||
{$ifdef BCB}
|
||||
{$ifdef CheckHeapForCorruption}
|
||||
{$define PatchBCBTerminate}
|
||||
{$else}
|
||||
{$ifdef DetectMMOperationsAfterUninstall}
|
||||
{$define PatchBCBTerminate}
|
||||
{$else}
|
||||
{$ifdef EnableMemoryLeakReporting}
|
||||
{$define PatchBCBTerminate}
|
||||
{$endif}
|
||||
{$endif}
|
||||
{$endif}
|
||||
|
||||
{$ifdef PatchBCBTerminate}
|
||||
{$define CheckCppObjectType}
|
||||
{$undef CheckCppObjectTypeEnabled}
|
||||
|
||||
{$ifdef CheckCppObjectType}
|
||||
{$define CheckCppObjectTypeEnabled}
|
||||
{$endif}
|
||||
|
||||
{Turn off "CheckCppObjectTypeEnabled" option if neither "CheckHeapForCorruption"
|
||||
option or "EnableMemoryLeakReporting" option were defined.}
|
||||
{$ifdef CheckHeapForCorruption}
|
||||
{$else}
|
||||
{$ifdef EnableMemoryLeakReporting}
|
||||
{$else}
|
||||
{$undef CheckCppObjectTypeEnabled}
|
||||
{$endif}
|
||||
{$endif}
|
||||
{$endif}
|
||||
{$endif}
|
BIN
contrib/mORMot/RTL7/FastMM4_AVX512.obj
Normal file
BIN
contrib/mORMot/RTL7/FastMM4_AVX512.obj
Normal file
Binary file not shown.
Reference in New Issue
Block a user