First, you have to identify memory or resource leak which you want to ignore. You can identify leak by:
|•||Leak type (data, string, array, object, etc.);|
Once leak is identified - you can instruct EurekaLog to ignore this leak. There are few available methods. Not all methods supports all of the features discussed above. This article covers the following options:
Important note: you can not use exception filters to ignore leaks, because leaks checking is performed as last step on shutdown - when all exception filters were already finalized.
Register a known memory leak.
EMemLeaks unit contains EurekaRegisterExpectedMemoryLeak, EurekaRegisterExpectedMemoryLeakDynArray, and EurekaRegisterExpectedMemoryLeakStr routines, which you may use to instruct EurekaLog to ignore leak of known location (variable). For example:
This can only work if you have access to the data which will be leaked.
Important note: be sure to register known leaks as late as possible - preferably on shutdown. This is to avoid cases when leaked variable may change its address due to re-allocating during normal work at run-time.
Use event handlers.
EMemLeaks unit contains global MemLeaksAdd procedure, which is assigned to default handler. You may assign your own handler to this variable. Similarly, EResLeaks unit contains ResLeaksAdd routine. For example:
procedure FilterLeaks(const AMemBlock: Pointer; const ABlockType: TBlockType;
const LeakDescription: String;
const LeakSingleSize, LeakTotalSize, LeakCount: PtrUInt;
const LeakCallStack: TCallStackArray);
function IgnoreThisLeak: Boolean;
// This is only an example, replace with your own code
Result := (ABlockType = btObject) and
(TObject(AMemBlock) is TMyObject) and
(LeakSingleSize = 64);
if IgnoreThisLeak then
AddLeak(AMemBlock, ABlockType, LeakDescription,
LeakSingleSize, LeakTotalSize, LeakCount,
AddLeak := MemLeaksAdd;
MemLeaksAdd := FilterLeaks;
Build date: 2020-04-11
Last edited: 2018-12-19
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/how_to_ignore_leak.php