Root > Reference > All Units > EMemLeaks Unit

EMemLeaks Unit

Previous pageReturn to chapter overviewNext page   

Unit for diagnosing memory problems (leaks, overflows, etc.).

 

Remarks

This unit contains code for EurekaLog's memory manager filter. This filter allows EurekaLog to check for memory problems, such as leaks, overflows, double-free, cross-module free, etc.

 

This unit does not contains implementation of real memory manager. This is memory filter only. It uses already installed memory manager to allocate and dispose memory.

 

EurekaLog's memory filter will add a little overhead for each memory allocation. EurekaLog stores additional header with call stack and other service information with each memory block. This header allows EurekaLog to check for memory problems.

 

Disabling memory leaks checks will significantly decrease size of added overhead (by removing call stack, name, etc.), but not remove overhead completely.

 

Additionally, a memory filter from EMemLeaks unit provide a way to associate exception object with exception information without using hooks. This allows EurekaLog to implement a clean way to exception tracing - which is useful for protection software. That is why it is very important to try to keep "Enable extended memory manager" option checked - even if you disable all other memory options.

 

Most routines from EMemLeaks unit should not be called from your code. Exceptions to this rule are:

 

Note

EMemLeaks unit is always included in uses clause when EurekaLog is enabled. Even if memory leaks and problems checks are disabled.

 

That is because memory checks can be enabled at run-time (programmatically or via command-line switches).

 

Note

EMemLeaks unit is included in uses clause when "Enable extended memory manager" option is checked.

 

Tip

"Enable extended memory manager" option can be enabled without enabling EurekaLog (via "Activate EurekaLog" option). This allows you to have EurekaLog memory manager for DLLs compiled without EurekaLog (for example, when you use "DLL" profile).

 

Warning

EMemLeaks unit must be a first unit to be initialized in your application.

 

There must be no active memory allocations before its initialization.

 

For this reason this unit must be a first unit in uses clause of your project.

 

Important!

It is highly important to have compatible memory managers in all modules which use shared memory manager. Therefore, if you are going to use shared memory manager - it is best to enable EMemLeaks unit in all your DLLs and EXE.

 

Pay close attention to statically linked DLLs, as such DLLs are loaded and initialized before main EXE. This can lead to initialization of some units before EMemLeaks unit.

 

Important!

You can place the following units before EMemLeaks unit in uses clause of your project:

units with memory manager's implementation (such as FastMM4, SafeMM, etc.);
units without initialization section;
units with initialization section which does not allocate memory;
units with initialization section which does allocate memory, but releases all allocated memory before return.

Normally EurekaLog would not allow any non-EurekaLog unit to be placed before EMemLeaks unit. However, EurekaLog has list of exceptions for this rule. For example, EurekaLog would allow you to place FastMM, FastMM3, FastMM4, SafeMMInstall, ShareMem, FastShareMem, SimpleShareMem, FastMove, FastCode, FastObj, FastSys, etc. units before EMemLeaks unit. You can instruct EurekaLog to allow other units to be placed before EMemLeaks unit. To do that:

1. Go to "Project" / "EurekaLog options" IDE menu;
2. Go to "Advanced" / "Custom / Manual" section;
3. Add "PreInitUnits" option (without quotes) to any location;
4. Add your units to the value of this option. Separate unit names with comma (","). Do not use spaces.

 

See also




Send feedback... Build date: 2024-09-30
Last edited: 2024-09-30
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_unit_ememleaks.php