Root > Integral parts > Options > Features page > Memory problems page > Shared memory manager

Shared memory manager

Previous pageReturn to chapter overviewNext page   

Warning: this topic talks about using shared memory manager only. If you do not share the memory manager between executable modules (the default case) - then you can use any memory manager(s) in any combinations without limitations. Obviously, all sharing options must be turned off.

 

 

General information

1. EurekaLog is compatible with a shared memory manager as implemented in FastMM.
2. EurekaLog is not compatible with other implementations of a shared memory manager.

 

Therefore, if you're using a shared memory manager - then you must ensure that all executable modules are compatible with each other. You can do this by selecting (and following) one of the following scenarios:

You are using a 3rd party shared memory manager:
oall modules do not use EurekaLog at all
osome (all) modules use EurekaLog, but the "Enable extended memory manager" option is turned off for all modules
You are using the EurekaLog's shared memory manager:
oall modules use EurekaLog and both "Enable extended memory manager" and "Share memory manager" (or "Use existing shared memory manager") options are turned on for all modules
o[FastMM integration] some modules use FastMM with sharing enabled, some modules use EurekaLog with both "Enable extended memory manager" and "Share memory manager" (or "Use existing shared memory manager") option turned on for all EurekaLog-enabled modules

 

In other words, you can't have shared memory manager and different settings for "Enable extended memory manager" option in different modules. Consider enabling the "Enable extended memory manager" option as "using another memory manager". Obviously, in order to use shared memory manager, you must use the same memory manager in all modules. That's why you can't have different settings for "Enable extended memory manager" option.

 

If you're not using shared memory manager - then "Enable extended memory manager" option can be set differently for each individual module. Also, "Share memory manager" and "Use existing shared memory manager" options should be unchecked.

 

Important Warning: using any memory leaks detection feature with any shared memory manager (no matter how it is implemented) is a very bad idea. Consider the following case:

1. Your EXE loads DLL;

2. DLL links into your EXE's memory manager;

3. DLL allocates memory (which is actually "your EXE allocates memory");

4. DLL unloads without deallocating the memory from step 3;

5. EXE shutdowns;

6. EXE's memory leaks detection will find a leak (allocated on step 3);

7. EXE will be unable to get a meaningful report, because the DLL that allocated the memory is already unloaded.

If you want to have a useful leaks detection - you will have to refactor your DLL API by removing dependence on a shared memory manager. Moral of the story: if you are using a shared memory manager - you should turn off memory leaks checks. However, you can use other debugging memory features.

 

 

Using EurekaLog and FastMM together

If you are not using shared memory manager - you can mix FastMM and EurekaLog in your modules in any combinations. Obviously, all sharing options must be turned off.
If you are using a shared memory manager - you must enable the "ShareMM" option for FastMM for non-EurekaLog modules (please, refer to FastMM's documentation) and you must enable both "Enable extended memory manager" and "Share memory manager" options for EurekaLog's modules. With these settings - you can mix FastMM and EurekaLog in your modules in any combinations.

 

Since EurekaLog is compatible with FastMM - you can (for example):

1. Compile .exe with EurekaLog and both "Enable extended memory manager" and "Share memory manager" options checked;

and

2. You can compile DLL (without EurekaLog) with FastMM and "ShareMM" option enabled.

 

The above would work:

The application will use EurekaLog's debugging features, if the .exe is initialized first. DLL(s) will use EurekaLog's shared memory manager from the .exe.
However, if you statically link a DLL to the .exe - the DLL will be initialized first. Therefore, FastMM (from the DLL) will be used as application's memory manager. Thus, EurekaLog's memory debugging capabilities (from the .exe) will be disabled.

 

To always use EurekaLog's memory manager:

do not statically link to DLLs, use dynamic loading

or

use EurekaLog in all modules

or

do not use shared memory manager

 

Warning: in case you use both FastMM and EurekaLog in the same module:

be sure to list FastMM's unit first and EurekaLog's unit second in the uses clause of the main .dpr file (regardless of the selected options)

and

do not enable the "ShareMM" option in FastMM for EurekaLog's modules

or

disable the "Enable extended memory manager" option

 

 

Using EurekaLog and Delphi (2007+) together

Starting with Delphi 2007 - there are standard AttemptToUseSharedMemoryManager and ShareMemoryManager functions, which you can use for sharing memory manager. These functions are wrappers for FastMM's sharing functionality (which is a standard memory manager since Delphi 2006).

 

Thus, this case is the same as "Using EurekaLog and FastMM together", but instead of FastMM and setting the "ShareMM" option you can use the ShareMemoryManager function. All notes, warnings, gotchas from the "Using EurekaLog and FastMM together" case are also applied here.

 

 

Using EurekaLog and SimpleShareMem together

The SimpleShareMem unit is a wrapper for the AttemptToUseSharedMemoryManager and ShareMemoryManager functions (see above).

 

Thus, this case is the same as "Using EurekaLog and FastMM together", but instead of FastMM and setting the "ShareMM" option you can use the SimpleShareMem unit. All notes, warnings, gotchas from the "Using EurekaLog and FastMM together" case are also applied here.

 

 

Using EurekaLog and borlndmm.dll or ShareMem together

EurekaLog is not compatible with BorlandMM.dll and the ShareMem unit. It is recommended to use FastMM with the "ShareMM" option (or the ShareMemoryManager function, or the SimpleShareMem unit) instead - see above. If it is not possible - then you must disable "Enable extended memory manager" option for all your EurekaLog-enabled modules (see the "General information" section above). Using of EurekaLog's debugging capabilities will be not possible.

 

Note: other EurekaLog's features (not memory-related) still will be accessible.

 

 

Using EurekaLog and dynamic RTL in C++ Builder together

EurekaLog is not compatible with BorlandMM.dll and the dynamic RTL in C++ Builder. It's recommended to use statically-linked RTL instead. If this is not possible - then you must disable "Enable extended memory manager" option for all your EurekaLog-enabled modules. Using of EurekaLog's debugging capabilities will be not possible.

 

Note: other EurekaLog's features (not memory-related) still will be accessible.

 

 

Using EurekaLog and other 3rd party memory manager together

EurekaLog is not compatible with other shared memory managers. It is recommended to use FastMM with the "ShareMM" option (or the ShareMemoryManager function, or the SimpleShareMem unit) instead - see above. If this is not possible - then you must disable "Enable extended memory manager" option for all your EurekaLog-enabled modules. Using of EurekaLog's debugging capabilities will be not possible. You may only use capabilities of your shared memory manager, but not EurekaLog.

 

Note: other EurekaLog's features (not memory-related) still will be accessible.

 

 

What can go wrong

If you'll use wrong settings - you can get these issues:

false-positive memory leaks;
missing memory leaks;
heap corruption reports;
access violations;
application's crash.

 

Typical reasons for these issues include the following:

Your code lists units in wrong order. For example, FastMM/SimpleShareMem/etc is not the first unit in uses of .dpr;
Your code uses conflicted settings. For example, DLL is compiled with ShareMem, but .exe is compiled with EurekaLog's "Enable extended memory manager" option.

 

 

See also:




Send feedback... Build date: 2024-09-30
Last edited: 2024-07-17
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/shared_memory_manager.php