FASTMM memory leaks

Source: Internet
Author: User
Tags set set

Transferred from: http://www.2ccc.com/article.asp?articleid=4879
FASTMM is a very good memory manager, but the option to find the right program from the Fastmm4options.inc is an English entanglement, so I've translated all the English notes in this file into Chinese. If you find any translation inappropriate, you can change it directly. Oh, to FASTMM author wrote an email, this file will also be included in the next FASTMM version.
If you do not want to download, directly copy the following content into the Fastmm4options.inc file and overwrite the original file content. The following is a translation of the latest version of FastMM4.84, the previous version can be referred to the comparison.

{

Fast Memory Manager: Option configuration file

Set the default options for FASTMM here

FASTMM 4.84

}

{
Simplified Chinese translation by Qianyuan Wang

Contact me if you find any improper translation.
Please contact me if there is any inappropriate translation.

e-mail: [Email protected]
}

{
Translation of each compilation option (no terminology is explained)

Align16bytes by 16-byte alignment
Usecustomfixedsizemoveroutines using fixed-size memory move functions
Usecustomvariablesizemoveroutines using variable-size memory move functions
Assumemultithreaded by multithreading
neversleeponthreadcontention thread conflicts without pausing a process
Installonlyifrunninginide only load the memory manager in the Delphi development environment
Neveruninstall Do not unload FASTMM
Useruntimepackages using Run-time packages

Nodebuginfo No debug information
Nomessageboxes does not display information
Useoutputdebugstring using the Windows API OutputDebugString
Asmversion Assembly version
Checkheapforcorruption Detecting Heap Errors
Detectmmoperationsafteruninstall Detecting a reference operation to a manager after it has been unloaded
Fulldebugmode Full Debug mode
Rawstacktraces thorough stack tracking
Catchuseoffreedinterfaces capturing references to objects that have been destroyed
Logerrorstofile Log errors to file
Logmemoryleakdetailtofile record memory leak details to file
Clearlogfileonstartup emptying log files at startup
loaddebugdlldynamically dynamically loading Debug DLLs
Alwaysallocatetopdown always allocates memory from the top

enablememoryleakreporting Allow memory leak reporting
Hideexpectedleaksregisteredbypointer hiding possible memory leaks recorded by the pointer
Requireidepresenceforleakreporting leak reporting only when IDE is present
Requiredebuggerpresenceforleakreporting leak reporting only when the debugger is present
Requiredebuginfoforleakreporting leak report requires debug information
Manualleakreportingcontrol Manual Control Leak report
Hidememoryleakhintmessage Hidden memory leak hint information

ENABLEMMX allows the use of MMX
FORCEMMX forced use of MMX

Sharemm Shared Memory Manager
Sharemmiflibrary allows the memory manager to be shared in the DLL
ATTEMPTTOUSESHAREDMM trying to share the memory manager
Enablebackwardcompatiblemmsharing Allow backward-compatible memory manager sharing

Fulldebugmodeinide Full commissioning in Delphi development environment
}

{----------Comprehensive options----------}

{Turning on this option aligns all memory blocks to 16-byte alignment so that the SSE instructions are safe to use. If this option is turned off, some
The smallest chunk of memory is aligned in 8-byte fashion, which reduces memory usage. Whether or not this option is turned on, medium and large internal
The save blocks are aligned in 16-byte fashion. }
{. $define align16bytes}

{Allows you to use a faster fixed-size memory move function when increasing small blocks of memory.} Because these functions are designed to move fixed dimensions
Memory, so the efficiency is significantly higher than the Borland in the RTL memory movement function. This option can be used in conjunction with the Fastmove Library
To achieve higher efficiency. }
{$define Usecustomfixedsizemoveroutines}

{Turn on this option to use an optimized function to move a block of memory of any size. Disabled when using Fastcode's Fastmove function
This option. Using Fastmove code allows the entire program to use faster memory movement functions rather than just memory management
Manager It is therefore recommended that you combine the FASTMM and Fastmove code and turn off this option. }
{$define Usecustomvariablesizemoveroutines}

{The default program is multithreaded after it is turned on, but it can cause a noticeable decrease in the speed of single threaded programs. In use may not be set correctly
Turn on this option when you place a multithreaded third-party tool with Ismultithread variables. In single-threaded main programs and multithreaded DLLs
Also need to be turned on when sharing the memory manager. }
{. $define assumemultithreaded}

{Turning on this option will not cause a thread to pause while the active process is low (less than 2) when the number of CPU cores
will increase the speed. When turned on, a thread will enter the "Wait" loop instead of the time slice when the conflict occurs. }
{. $define neversleeponthreadcontention}

{Turning on this option causes the program to be FASTMM as a memory manager only when it runs inside the Delphi IDE.} When you want to publish the
EXE is the exe you debug, but only if you want to use debugging on the development host, turn on this option. When the program is opened, it is not
Run on the development host, it will use the default Delphi memory manager (after Delphi2006 is not turned on Fulldebugmode
FASTMM)}
{. $InstallOnlyIfRunningInIDE}

{Because qc#14070 (Delphi tries to free memory after the borlandmm.dll shutdown instruction is executed), when using the FASTMM
As a substitute for the core Borlandmm.dll, FASTMM cannot be unloaded properly. Turning on this option does not uninstall the memory manager
And avoid this mistake. }
{. $define Neveruninstall}

{You need to start this option if you are using a run-time package in the current project.} The assumemultithreaded is automatically turned on.
Note You must make sure that all pointers are released after FASTMM is unloaded. If you do not do this, you will have a large A/V
A large memory leak report. (see frequently Asked questions) You must also start this option and the Neveruninstall option. }
{. $define useruntimepackages}

{----------Debugging Options----------}

{Turning on this option will not generate debug code for the Fastmm4.pas unit, it will also prevent the debugger from entering the Fastmm4.pas unit}
{. $define nodebuginfo}

{Turning on the option below will not display any information and is useful in non-aborted server programs}
{. $define nomessageboxes}

{If you want to use the Windows API OutputDebugString procedure to display debugging information, turn on the following option}
{. $define useoutputdebugstring}

{Turning on this option will use the assembly language version of FASTMM, which is faster than the Pascal version. This option is only turned off during debugging.
Turning on checkheapforcorruption automatically turns off this setting}
{$define Asmversion}

{FASTMM always catches a bad operation of the same memory area that was released two times, it can also detect heap errors (usually
Read and write memory across the program). These tests are time-consuming, so this option should be used only when debugging. If this option
Open, Asmversion will automatically close}
{. $define checkheapforcorruption}

{Turn on this option to detect a user's reference to FASTMM after FASTMM has been uninstalled.} After opening, when FASTMM is uninstalled,
The previous memory manager will not be restarted, but there is a hypothetical memory manager, and once the memory operation is
Throws an error. This catches the error that the program is still doing memory operations when FASTMM has been uninstalled. }
{$define Detectmmoperationsafteruninstall}

{Set the following options for extensive detection of memory leaks.} All memory blocks are set with the block header and tracker to verify the end of the heap
of the whole. The freed memory blocks (pointers) are also emptied to ensure that they are not reused. This option will significantly reduce
Low memory operation speed, used only if you are debugging a program that will cross-write memory or reuse a pointer that has been disposed of.
Turning on this option will automatically turn on checkheapforcorruption and automatically turn off asmversion. Tip: When you turn on
When this option is used, the program needs to use the Fastmm_fulldebugmode.dll file. If this file is missing, the program will not start. }
{. $define Fulldebugmode}

{Turn on this option for thorough stack tracking: detects all stack entries to find a valid return address. Note that this is better than using
The main stack frame method is much slower, but more thorough. This option is available only when Fulldebugmode is turned on. }
{$define Rawstacktraces}

{Turn on this option to detect references to objects that have been destroyed in your program.} Note that this causes the pair to be released and modified (the content is
Overwrite) The detection of a block of memory is not possible (both cannot coexist). This option is available only when Fulldebugmode is turned on. }
{. $define catchuseoffreedinterfaces}

{Turn on this option to log all errors to a text file that is in the same directory as the program.} Memory allocation error (when opening
Fulldebugmode) will be added to this log. This option is invalid if Fulldebugmode is turned off}
{$define Logerrorstofile}

{Turning on this option will log all leaks to a text file that is in the same directory as the program.} Memory leak report (when opening
Fulldebugmode) will be added to this log. If "Logerrorstofile" and "Fulldebugmode" are not open
This option is not valid. Note that all leaks are usually recorded, even those that are addexpectedmemoryleaks identified.
Possible memory leaks. Possible leaks caused by pointers may be due to the opening of hideexpectedleaks-
Registeredbypointer and not displayed. }
{$define Logmemoryleakdetailtofile}

{The log file is deleted when the program starts.} Invalid when Logerrorstofile is not turned on}
{. $define Clearlogfileonstartup}

{Whether Fastmm_fulldebugmode.dll is dynamically linked.} If the DLL is not found, the stack trace will not be able to proceed. Attention
Errors may occur when the shared Memory manager is changed due to DLL unload order. }
{. $define loaddebugdlldynamically}

{FASTMM typically uses the topmost available address to allocate a large block of memory, while allocating it on the lowest-available address
Medium and small chunks of memory (this reduces fragmentation to some extent). Turning on this option causes the memory allocation to always take precedence over the top
Address available on the server. If the process uses more than 2GB of memory and the algorithm has poor pointer assignment, this option
Item will help to find the error early}
{$define Alwaysallocatetopdown}

{----------memory leak report----------}

{Turn on this option to allow a memory leak report to be used in combination with the following two options. }
{$define enablememoryleakreporting}

{Turning on the option below will not show and record possible memory leaks caused by the pointer type.} caused by a class (pointer)
The possible memory leaks are often ambiguous, so these possible leaks are always logged to the log (in Fulldebugmode
When the logmemoryleakdetailtofile is turned on) and will be displayed when the actual leak is longer than expected. }
{$define Hideexpectedleaksregisteredbypointer}

{The following option is turned on to report a memory leak only if Delphi exists on the host. When "enablememoryleakreporting"
This option is not valid when closed. }
{. $define requireidepresenceforleakreporting}

{The following option is turned on to report a memory leak only when the program is debugged in Delphi.} When "enablememoryleakreporting"
This option is not valid when closed. This option is only valid when debugging an EXE project and does not support DLLs}
{$define requiredebuggerpresenceforleakreporting}

{Turn on the following option to implement leak detection only if there is a debug indicator ($D) in the compiled unit. When
This option is not valid when "enablememoryleakreporting" is closed. }
{. $define requiredebuginfoforleakreporting}

{Turn on this option to manually control the memory leak report.} When turned on, Reportmemoryleaksonshutdown (program
Report a memory leak when off, default off) to choose whether to generate a report instead. Other leak detection options when turned on
must also be set correctly for detection}
{. $define Manualleakreportingcontrol}

{The following option will not display the following prompt for memory leak information}
{. $define hidememoryleakhintmessage}

{----------instruction set set----------}

{Turn on the following option to use the MMX instruction set.} Turning off this option can cause a slight performance decrease, but will be associated with AMD K5,
Pentium I and other early processors remain compatible. The MMX directive is currently used only in variable-size memory movements, so
Usecustomvariablesizemoveroutines closed, this option is not valid. }
{. $define enablemmx}

{Turn on the following option to force the MMX instruction set, regardless of whether the CPU supports it. If this option is turned off,
The CPU will first be checked to see if the MMX instructions are supported. Invalid when ENABLEDMMX is closed. }
{$define FORCEMMX}

{----------Shared Memory Manager Settings----------}

{Allows shared memory manager between the main program and the DLL that are compiled using FASTMM. You can pass to a function in a DLL
Dynamic arrays and long strings. You need to turn on ATTEMPTTOUSESHAREDMM when compiling the DLL to really implement memory sharing.
Note If the main program is single threaded and the DLL is multithreaded, you must open Ismultithread in the main program, otherwise
The program crashes when a thread conflicts. Note that statically linked DLLs are initialized before the main program, so the main program actually
DLL shared Memory manager.
}
{. $define Sharemm}

{Allows a memory manager to be shared between DLLs (or between statically linked DLLs and the main program), requiring common use of FASTMM compilation.
You need to be aware of DLL usage when using dynamic linking, because if the DLL is unloaded and the other DLLs are still sharing the memory manager, the process
The sequence will crash. This option is only relevant to DLL libraries and requires SHAREMM and ATTEMPTTOUSESHAREDMM to be turned on. Attention
If the DLLs are statically linked, they are initialized before the main program, which is actually the main program with which they share the manager. When
This option is invalid when SHAREMM is closed}
{. $define sharemmiflibrary}

{The following option is turned on to attempt to share memory management between the main program and the DLL that is co-compiled with it (also turn on this option)
Manager When sharing, leaks generated by using the sharer will not be automatically purged. Because statically linked DLLs are in the main program
Previously initialized, so set the sharing options as appropriate}
{. $define attempttousesharedmm}

{Turn on the following compilation options to ensure backward compatibility with the memory manager.} To Delphi2006 and Delphi2007 with the old version
FASTMM valid}
{$define enablebackwardcompatiblemmsharing}

{----------combination settings----------}

{Turn on this option to activate Fulldebugmode, Installonlyifrunninginide, loaddebugdlldynamically.
If the program is being debugged in Delphi, FASTMM will be fully debugged (turn on fulldebugmode), otherwise
The default memory manager will be used (Delphi2006 version is not turned on for Fulldebugmode FASTMM). }
{. $define fulldebugmodeinide}

{Quick configuration of Release and debug versions}
{$ifdef Release}
{Release version please set}
{. $undef Fulldebugmode}
{. $undef checkheapforcorruption}
{. $define asmversion}
{. $undef enablememoryleakreporting}
{. $undef useoutputdebugstring}
{$else}
{Debug version Please set}
{. $define Fulldebugmode}
{. $define enablememoryleakreporting}
{. $define useoutputdebugstring}
{$ENDIF}

{----------borlndmm.dll compilation option----------}
{If you are recompiling the Borlandmm.dll file, set the following options as needed}

{Turn on this option when compiling Borlandmm.dll}
{. $define Borlndmmdll}

{If the DLL is used by Delphi itself, turn on this option}
{. $define dllforide}

{Turn on this option when compiling the debug DLL file}
{. $define Debugdll}

{Please do not change the following}
{$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}

{Put the relevant settings for BCB here. With the "Build with Dynamic RTL" option turned on,
cb2006/cb2007 can compile Borlandmm.dll files to track memory leaks. }
{----------Set----------} specifically for BCB}

{To open a patch prepared for BCB, you need to "Project options->pascal/delphi compiler->defines"
The definition of BCB is added. (Thanks to Jiyuan Xie for this part)}

{$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}

{if both "checkheapforcorruption" and "enablememoryleakreporting" are not turned on, please close
"Checkcppobjecttypeenabled"}
{$ifdef Checkheapforcorruption}
{$else}
{$ifdef enablememoryleakreporting}
{$else}
{$undef checkcppobjecttypeenabled}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}

Fastmm_fulldebugmode.dll, to copy to the same directory as the program, only report

Http://wenku.baidu.com/view/abc90ffa700abb68a982fbd7.html

Http://www.docin.com/p-554628531.html

Http://wenku.baidu.com/view/ea59b8010740be1e650e9a59.html

FASTMM memory leaks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.