<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title><![CDATA[EurekaLab s.a.s.]]></title>
<link><![CDATA[https://support.eurekalog.com/]]></link>
<description />
<generator><![CDATA[Kayako Resolve v4.51.1891]]></generator>
<item>
<title><![CDATA[7.x: Out of memory when using EurekaLog]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/98]]></link>
<guid isPermaLink="false"><![CDATA[ed3d2c21991e3bef5e069713af9fa6ca]]></guid>
<pubDate><![CDATA[Thu, 13 Feb 2025 12:32:23 +0000]]></pubDate>
<dc:creator />
<description><![CDATA[Problem:
My application runs just fine when compiled&nbsp;without EurekaLog.
However, if I compile it with EurekaLog:

I am being stopped at the ELowLevel.DebugBreak&nbsp;being called from EBase.PanicModeOn when run under debugger;
If I continue exec...]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>My application runs just fine when compiled&nbsp;<strong>without</strong> EurekaLog.</p>
<p>However, if I compile it <strong>with</strong> EurekaLog:</p>
<ul>
<li>I am being stopped at the <span style="font-family: &quot;courier new&quot;, courier;">ELowLevel.DebugBreak</span>&nbsp;being called from <span style="font-family: &quot;courier new&quot;, courier;">EBase.PanicModeOn</span> when run under debugger;</li>
<li>If I continue execution (or simply run outside debugger) - I get the following error dialog:</li>
</ul>
<span style="font-family: &quot;courier new&quot;, courier;">The application has encountered a problem. We are sorry for the inconvenience.</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Out of memory:</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 1112 (1.09 Kb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 1183744 (1.13 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL):&nbsp;1887792563 (1.76 Gb) (1945427109 (1.81 Gb))</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 2076430336 (1.93 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total available (RAM): 21130706944 (19.68 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total available (page file): 20763758592 (19.34 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total (RAM): 34297835520 (31.94 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total (page file): 38592802816 (35.94 Gb)<br /></span>
<p>&nbsp;</p>
<h2>Reason:</h2>
<p>EurekaLog has <em>memory </em>checks enabled by default.&nbsp;Please note that "<em>leaks </em>checks" and "<em>memory </em>checks" are two different things. You can enable <em>memory </em>checks while having <em>leaks </em>checks disabled (which is a default case). On the other hand, you can't have <em>leaks </em>checks enabled while <em>memory </em>checks are disabled.</p>
<p>If <em>memory </em>checks are enabled:&nbsp;<strong>each</strong> memory allocation in your application will have a larger size to store extra information (header/footer) required for checks to work:</p>
<ul>
<li><em>Leaks </em>checks are <strong>disabled</strong> (default): each memory allocation will be larger on <strong>32 bytes</strong> (to store block's info, flags, sentry values, see <span style="font-family: &quot;courier new&quot;, courier;">ETypes.TPointerDummyRecord</span>, <span style="font-family: &quot;courier new&quot;, courier;">ETypes.BlockDummyOverHead</span>);</li>
<li><em>Leaks </em>checks are <strong>enabled</strong>: each memory allocation will be larger on <strong>272 bytes</strong> (to store call stack, see <span style="font-family: &quot;courier new&quot;, courier;">ETypes.TPointerRecord</span>, <span style="font-family: &quot;courier new&quot;, courier;">ETypes.TPointerFooter</span>, <span style="font-family: &quot;courier new&quot;, courier;">ETypes.BlockOverHead</span>, ETypes.BlockOverFoot).</li>
</ul>
<p>For example:</p>
<ol>
<li> If you allocate 8 bytes 1'000 times: your application would allocate (8 + 32) x 1'000 = 40'000 bytes instead of the usual 8'000 bytes resulting in the overhead from EurekaLog (not including overhead from memory manager itself) of 32'000 bytes (<strong>x5 overhead</strong>);</li>
<li>On the other hand, if you allocate 200 bytes 1'000 times: your application would allocate (200 + 32) x 1'000 =&nbsp;232'000 bytes instead of the usual 200'000 bytes resulting in the same overhead of 32'000 bytes, but now it is just <strong>x1.16 overhead</strong>;</li>
<li>Finally, if you disable memory checks altogether (the <a title="Memory problems page" href="https://www.eurekalog.com/help/eurekalog/memory_leaks_page.php">"Enable extended memory manager" option</a>): EurekaLog won't be installing a filter on your memory manager, thus all your memory allocations will be unaffected by EuekaLog resulting in <strong>0 overhead</strong>.</li>
</ol>
<p>Conclusion: the larger your allocated memory blocks are = the less overhead. Worst case is like allocating simple&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">TObject</span>s - which are just 8 bytes (<span style="font-family: &quot;courier new&quot;, courier;">.InstanceSize</span> method).</p>
<p>&nbsp;</p>
<h2>Diagnostic:</h2>
<ul>
<li>The "<strong>Allocating</strong>" value indicates argument for the&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">GetMem</span>, <span style="font-family: &quot;courier new&quot;, courier;">AllocMem</span> or a similar function. It indicates how much bytes your application tried to allocate when it failed. This value may be missing - for example, if memory checks are disabled (so RTL's default memory manager is used).</li>
<li>The "<strong>Largest available</strong>" value indicates the size of the largest <strong>continuous </strong>free (unoccupied) memory block in your application. This value is obtained by scanning your address space looking for a <span style="font-family: &quot;courier new&quot;, courier;">MEM_FREE</span> region of a largest <span style="font-family: &quot;courier new&quot;, courier;">RegionSize</span>.</li>
<li>The "<strong>Total allocated (RTL)</strong>" value indicate how much memory was allocated via RTL memory functions (<span style="font-family: &quot;courier new&quot;, courier;">GetMem</span>,&nbsp;<span><span style="font-family: &quot;courier new&quot;, courier;">AllocMem</span>, etc.</span>). It can be either a single value or two values:&nbsp;
<ul>
<li>One value: it is shown when EurekaLog memory filter is not installed, so all allocations go through the default RTL memory manager (or a 3rd party memory manager, if you have one installed);</li>
<li>Two values: it is shown when EurekaLog memory filter is installed, so allocations go through EurekaLog. Two values indicate total size of all allocations without and with overhead from EurekaLog.</li>
</ul>
</li>
<li>The "<strong>Total allocated (virtual)</strong>" value is equal to&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">ullTotalVirtual</span> - <span style="font-family: &quot;courier new&quot;, courier;">ullAvailVirtual</span> from the&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">GlobalMemoryStatusEx</span>. It indicates how much memory is allocated (or reserved) in your address space. This includes loaded modules (exe, DLL, bpl), memory allocated via RTL, memory allocated by 3rd party code (system, DLLs, etc).</li>
<li>The "<strong>Total available (RAM)</strong>" and "<strong>Total available (page file)</strong>" indicate free space in RAM and page file respectively.</li>
<li>The "<strong>Total (RAM)</strong>" and "<strong>Total (page file)</strong>" indicate total size of RAM and page file respectively.</li>
</ul>
<p>You need to analyze these values in order to understand why "out of memory" exception was thrown.</p>
<p><span style="color: #ff0000;"><strong>IMPORTANT:</strong></span> keep in mind - the memory is not static, it is always changing. It means, the memory <strong>will </strong>be changed between the moment exception was thrown and bug report was created. Therefore, various values from the error message and from the bug report may not be 100% accurate. Don't expect a perfect match, but look for generic patterns - see examples below.</p>
<p>&nbsp;</p>
<p>A). If the "total allocated (virtual)" value is close to the possible maximum of address space for your application:</p>
<ul>
<li>2 Gb for normal 32-bit app;</li>
<li>3 Gb for large address awared 32-bit app on 32-bit system;</li>
<li>4 Gb for large&nbsp;address awared 32-bit app on 64-bit system;</li>
<li>8 or 128 Tb for 64-bit app (depends on Windows version).</li>
</ul>
<p>then you have a real out of memory error, because you have exhausted all free memory in your application.</p>
<p>For example:</p>
<p><span style="font-family: &quot;courier new&quot;, courier;"><span>Allocating: 1112 (1.09 Kb)</span><br /><span>Largest available: 1183744 (1.13 Mb)</span><br /><span>Total allocated (RTL):&nbsp;1887792563 (1.76 Gb) (1945427109 (1.81 Gb))</span><br /><span>Total allocated (virtual): 2076430336 (<strong>1.93 Gb</strong>)</span><br /><span>Total available (RAM): 21130706944 (19.68 Gb)</span><br /><span>Total available (page file): 20763758592 (19.34 Gb)</span><br /><span>Total (RAM): 34297835520 (31.94 Gb)</span><br /><span>Total (page file): 38592802816 (35.94 Gb)</span></span></p>
<p>As you can see, the&nbsp;"total allocated (virtual)" value is 1.93 Gb, which is pretty close to the possible maximum of 2.0 Gb for a normal 32-bit app. Therefore, it is an error message about real out of memory error, because you have used up all of your 2 Gb of available memory.</p>
<p>&nbsp;</p>
<p>B). If the "total allocated (virtual)" value is not near the possible maximum limit for your application (outlined in the section A above), but the "total available (page file)" value is very low:&nbsp;you have a real out of memory error. It is <strong>not </strong>because you&nbsp;have exhausted all free memory in your application, but it is because your system does not have enough memory available.</p>
<p>For example:</p>
<span style="font-family: &quot;courier new&quot;, courier;">Allocating: 456</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 406913024 (388.06 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 779572038 (743.46 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 874307584 (<strong>833.80 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total available (RAM): <span>5758976 (</span>5.49 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total available (page file): 5758976 (<strong>5.49 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total (RAM): <span>1026299904</span> (1 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total (page file): 1506299904 (1.40 Gb)</span><br />
<p>As you can see, while the&nbsp;"total allocated (virtual)" value (833.80 Mb) is far less than 2 Gb for a 32-bit app, but the paging memory has run out ("total available (page file)" is very low).</p>
<ul>
<li>For example, if your system has 8 Gb of RAM and has swap/paging file disabled, then system will have just 8&nbsp;Gb of memory for <strong>all</strong> applications. It means no application on such system can allocate more than&nbsp;8 Gb - which is far less of 8/128 Tb of possible max for 64-bit app.</li>
<li>Additionally, if other applications would occupy 7 Gb of memory already, your app would have just 1 Gb to run - which is less than even 2 Gb of possible max for 32-bit app.</li>
<li>Finally, a system may have swap/paging file, but its size may be limited by some value. Say, a system can have 8 Gb of RAM with 16 Gb of swap/paging file. The size of the swap/page file could be limited by system's settings or by simply running out of a free HDD space. Again, maximum memory size for all apps will be limited to 8 + 16 Gb, and will be less for your own app - depending on how many memory other apps have allocated.</li>
</ul>
<p>Specifically, the total amount of available memory for the system from the sample error message above is 1 Gb of RAM with 512 Mb of swap/page file, resulting in 1.5 Gb of total available memory.</p>
<p>So you may hit this limit, and while the&nbsp;"largest available" value would still show the largest continuous free block in your address space to be sufficiently large (or even huge for 64-bit apps), but the system doesn't have free memory to allow your app to actually allocate more memory.</p>
<p>&nbsp;</p>
<p>C). If the "total allocated (RTL)" value has two numbers and first number is <strong>significantly </strong>smaller than the second number: you have out of memory error because of the overhead from EurekaLog.</p>
<p>For example:&nbsp;</p>
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 1112 (1.09 Kb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 1183744 (1.13 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 373146095 (<strong>355.86 Mb</strong>) (<span>2072498176 (</span><strong>1.93 Gb</strong><span>))</span></span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 2072498176 (1.93 Gb)<br />Total available (page file): 20763758592 (19.34 Gb)<br />Total (page file): 38592802816 (35.94 Gb)</span></p>
<p>The second number in "total allocated (RTL)" (1.93 Gb) is significantly larger than the first number (355 Mb) - which means your code allocated a lot of small memory blocks (objects), so now you have a large overhead (about <strong>x5.4 times</strong>). In other words, you have out of memory error because of additional overhead from EurekaLog memory/leaks checks.</p>
<p>On the other hand:</p>
<span style="font-family: &quot;courier new&quot;, courier;">
<p style="font-family: &quot;courier new&quot;, courier;"><span>Allocating: 1112 (1.09 Kb)<br />Largest available: 1183744 (1.13 Mb)<br />Total allocated (RTL):&nbsp;1887792563 (<strong>1.76 Gb</strong>) (1945427109 (<strong>1.81 Gb</strong>))<br />Total allocated (virtual): 2076430336 (1.93 Gb)<br />Total available (RAM): 21130706944 (19.68 Gb)<br />Total available (page file): 20763758592 (19.34 Gb)<br />Total (RAM): 34297835520 (31.94 Gb)<br />Total (page file): 38592802816 (35.94 Gb)</span></p>
<div style="font-family: &quot;courier new&quot;, courier;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">While the first "total allocated (RTL)" value (1.76 Gb) is smaller than the&nbsp;second value (1.81 Gb), but the difference is not that big - resulting is a reasonable&nbsp;</span><strong style="font-family: Verdana, Arial, Helvetica, sans-serif;">x1.1 times</strong><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">&nbsp;overhead.&nbsp;In other words, you do </span><strong style="font-family: Verdana, Arial, Helvetica, sans-serif;">not </strong><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">have out of memory error because of additional overhead from EurekaLog memory/leaks checks.</span></div>
<div style="font-family: &quot;courier new&quot;, courier;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="font-family: &quot;courier new&quot;, courier;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">Another example:</span></div>
<div style="font-family: &quot;courier new&quot;, courier;"><span>
<p>Allocating: 1112 (1.09 Kb)<br />Largest available: 1183744 (1.13 Mb)<br />Total allocated (RTL):&nbsp;1887792563 (<strong>1.76 Gb</strong>)<br />Total allocated (virtual): 2076430336 (1.93 Gb)<br />Total available (RAM): 21130706944 (19.68 Gb)<br />Total available (page file): 20763758592 (19.34 Gb)<br />Total (RAM): 34297835520 (31.94 Gb)<br />Total (page file): 38592802816 (35.94 Gb)</p>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">The&nbsp;</span><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">"total allocated (RTL)" has only one value, which means there is no overhead from EurekaLog.</span></div>
<div></div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;"><br /></span></div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">D). If the&nbsp;"total allocated (RTL)" value is significantly smaller than&nbsp;the&nbsp;"total allocated (virtual)" value: you have a real out of memory error because 3rd party code&nbsp;(such as non-Delphi code, DLLs, system) has exhausted all free memory in your application.</span><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">&nbsp;</span></div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;"><br /></span></div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">For example:&nbsp;</span></div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 1112 (1.09 Kb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 1183744 (1.13 Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 373146095 (<strong>355.86 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 2072498176 (<strong>1.93 Gb</strong>)<br />Total available (page file): 20763758592 (19.34 Gb)<br />Total (page file): 38592802816 (35.94 Gb)</span></p>
<p>The largest value in the "total allocated (RTL)" (355 Mb) is significantly smaller than&nbsp;the&nbsp;"total allocated (virtual)" value (1.93 Gb) - which means most of your memory is occupied with data allocated not through RTL's memory manager. This includes memory allocated by the system, loaded DLLs, and even non-RTL code in your app (statically linked .obj-s, etc.).</p>
<p>&nbsp;</p>
<p>E). If the "largest available" value is about few Mb in size and/or less than the "Allocating" value, but the "total allocated (virtual)" value is <strong>not </strong>close to the maximum possible limit (see sections A above) and the "total available (page file)" value is large enough (see section B above): you have out of memory error because of memory fragmentation.</p>
</span></div>
</span></div>
</span>
<p>For example:</p>
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: <span>1183744 (</span>1.13 Mb<span>)</span></span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: <span>867882</span> (<strong>847.54 Kb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 686788239 (654.97&nbsp;Mb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 1086788239 (<strong>1 Gb</strong>)<br />Total available (page file): 20763758592 (<strong>19.34 Gb</strong>)<br />Total (page file): 38592802816 (35.94 Gb)</span></p>
<p>As you can see, there is plenty of free memory available in your application, because&nbsp;the "total allocated (virtual)" value (1 Gb) is not reaching the limit (2 Gb for a normal 32-bit app, see section A above)&nbsp;and the "total available (page file)" value is not hitting the system's limit (see section B above). However, the "largest available" value is very small - smaller than the requested memory (1.13 Mb). It is the classic symptom of a memory fragmentation: you try to allocate a (large) block and you can't, even though you appear to have enough free memory.</p>
<p>&nbsp;</p>
<p>F). If the "largest available" value is more than few Mb in size <strong>and </strong>is significantly larger than the "Allocating" value, while the "total allocated (virtual)" value is&nbsp;<strong>not&nbsp;</strong>close to the maximum possible limit (see section A above) and the "total available (page file)" value is large enough (see section B above): you probably do <strong>not </strong>have an out of memory error at all.&nbsp;</p>
<p>You see, memory allocation in Delphi (Builder) is implemented like so:</p>
<pre><span style="font-family: &quot;courier new&quot;, courier;">function GetMem(Size: NativeInt): Pointer;</span><br /><span style="font-family: &quot;courier new&quot;, courier;">begin</span><br /><span style="font-family: &quot;courier new&quot;, courier;">&nbsp; if Size = 0 then</span><br /><span style="font-family: &quot;courier new&quot;, courier;">&nbsp; &nbsp; Exit(nil);</span><br /><span style="font-family: &quot;courier new&quot;, courier;">&nbsp; Result := MemoryManager.GetMem(Size);</span><br /><span style="font-family: &quot;courier new&quot;, courier;">&nbsp; if Result = nil then</span><br /><span style="font-family: &quot;courier new&quot;, courier;">&nbsp; &nbsp; Error(reOutOfMemory);</span><br /><span style="font-family: &quot;courier new&quot;, courier;">end;</span></pre>
<p>As you can see, <strong>any </strong>memory allocation error is treated like "out of memory" error. So, what this error is saying is "unable to allocate memory" for <em>whatever</em> reason. It could&nbsp;be due to memory corruption bug somewhere. For example, a memory bug could damage control structures of the memory manager.</p>
<p>For example:</p>
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 1112 (<strong>1.09 Kb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 1183744 (<strong>1.13 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 1193750159 (1.11 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 2076430336 (1.93 Gb)<br /><span>Total available (page file): 20763758592 (19.34 Gb)</span><br /><span>Total (page file): 38592802816 (35.94 Gb)</span></span></p>
<p>Notice while the "largest available" value (1.13 Mb) is larger than the "allocating" value (1.09 Kb), but it is not <strong>significantly</strong> larger.</p>
<p>The reason the "largest available" value is larger than&nbsp;the "allocating" value is because your application does not allocate memory directly from the system. Instead, your allocation requests go to your app's memory manager, which is the FastMM by default (on modern IDEs). Memory manager allocate larger chunks from the system and then uses these chunks to serve memory allocation requests from your code. Specifically, FastMM uses chunks of about 1.2 Mb in size. As you can see the available free memory (1.13 Mb) is less than 1.2 Mb required for FastMM to allocate a new chunk. Therefore, this case is a real out of memory error.</p>
<p>Another example:</p>
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 2097152&nbsp;(<strong>2 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 1183744 (<strong>1.13 Mb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 1193750159 (1.11 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 2076430336 (1.93 Gb)<br />Total available (page file): 20763758592 (19.34 Gb)<br />Total (page file): 38592802816 (35.94 Gb)</span></p>
<p>Notice the "largest available" value (1.13 Mb) is smaller than the "allocating" value (2 Mb). Therefore, this case is a real out of memory error.</p>
<p>On the other hand:</p>
<p><span style="font-family: &quot;courier new&quot;, courier;">Allocating: 1112 (<strong>1.09 Kb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Largest available: 138109829251072 (<strong>125.6 Tb</strong>)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (RTL): 3522839902 (3.28 Gb)</span><br /><span style="font-family: &quot;courier new&quot;, courier;">Total allocated (virtual): 4914884608 (4.58 Gb)<br /><span>Total available (page file): 20763758592 (<strong>19.34 Gb</strong>)</span><br /><span>Total (page file): 38592802816 (35.94 Gb)</span></span></p>
<p>Notice&nbsp;the "largest available" value (125.6 Tb) is larger than few Mb and it is <strong>significantly </strong>larger than the "allocating" value (1.09 Kb), while the "<span>total allocated (virtual)</span>" is nowhere near close to the possible max and the "total available (page file)" indicate plently of free swap/page file space. All of this means: there is plenty of free memory in application, but request to allocate memory fails. Therefore, it is <strong>not </strong>a real out of memory error. It is a memory corruption error.</p>
<p>&nbsp;</p>
<h2>Solution:</h2>
<h3>A). Insufficient system's memory.</h3>
<p>If you have insufficient system's memory (not enough RAM or/and swap/page file) - fix it. Enable swap/page file (if disabled), increase size of the swap/page file, and/or install more RAM.</p>
<p>You may follow other advices below (especially if you have a large overhead from EurekaLog), but increasing your system's memory is a faster and easier way.</p>
<p>&nbsp;</p>
<h3>B). Memory corruption.</h3>
<p>If you have a memory corruption error - start searching for it.</p>
<p>We would recommend to enable memory <strong>and </strong>leaks checks in EurekaLog. Just be sure leaks checks are enabled (for example, you don't run your app outside debugger while having the <a title="Memory problems page" href="https://www.eurekalog.com/help/eurekalog/memory_leaks_page.php">"Active only when running under debugger" option</a> enabled).</p>
<p>If it did not help - try to use full-featured debugging memory manager. Such as FastMM in full debug mode, SafeMM, etc.</p>
<p>If it did not help - try to review your code.</p>
<p>&nbsp;</p>
<h3>C). Memory fragmentation.</h3>
<p><span>Memory fragmentation is when most of your memory is allocated in a large number of non-contiguous blocks, or chunks - leaving a good percentage of your total memory unallocated, but unusable for most typical scenarios.&nbsp;</span>If you have a memory fragmentation - start by reviewing your code.&nbsp;</p>
<p>First, ensure your code does not leak. Even a smallest leak of just 1 byte being repeated enough times can occupy your free memory dividing it into smaller blocks, thus causing fragmentation. Therefore, check your application for memory and resource leaks. Fix all leaks that you can find.</p>
<p>Second, once you are sure there are no leaks, and you left with pure memory fragmenation:&nbsp;review your code. Memory fragmentation is&nbsp;caused by the behavior of an application, it is about greatly different allocation lifetimes. In other words, some blocks/objects are allocated and freed regularly while other persist for long periods of time. The best thing you can do to address this type of a problem is logically divide objects by lifetimes. Basically, you want to have two (or more) heaps (pools) of temporal and permanent blocks/objects, or blocks/objects of a similar life-time. For example, if your application opens a file/document, you may want to allocate everything related to that file/document in a standalone heap/pool.</p>
<p><span>Additionally, you can reduce memory fragmentation by reducing the amount you allocate / deallocate. For example, you can use dynamic arrays as pool of various things, so instead of allocating a million of small objects - it is better to allocate a single array of small records. See also the "C). Out of memory" section below.</span></p>
<p><span>Notice that you can override the <span style="font-family: &quot;courier new&quot;, courier;">.NewInstance</span> method for some classes to allocate objects differently: say, on an array or via specific heap.</span></p>
<p>Finally, you may try to replace your memory manager with another one that offer low fragmentation allocations.</p>
<p>Generally you don't need to worry about memory fragmentation, unless your application is long-running and does a lot of allocation (and freeing). It starts to be a problem when you have a mix of short-lived and long-lived blocks/objects on a long distance. Therefore, if you have such application (such as service) - you may be able to restart it from time to time, if it is possible - thus avoiding memory fragmentation error in the first place.</p>
<p>&nbsp;</p>
<h3>D). Out of memory due to overhead.</h3>
<p>Running out of memory because of EurekaLog's overhead means your code allocates <strong>a lot</strong> of small memory blocks (objects).</p>
<p>If you have out of memory error because of added EurekaLog's overhead:</p>
<ol>
<li>If you need/want EurekaLog's features of memory and/or leaks checks: you can follow advices from the "E). Out of memory" section below to reduce memory footprint of your application and/or you can follow the "C). Memory fragmentation" section above to refactor your code to allocate memory more efficiently (less allocations, larger blocks);</li>
<li>If you don't need/want EurekaLog's features of memory and/or leaks checks: you can disable leaks checks in EurekaLog by unchecking the <a title="Memory problems page" href="https://www.eurekalog.com/help/eurekalog/memory_leaks_page.php">"Catch memory leaks" option</a>. If that did not help - you can disable memory checks in EurekaLog by unchecking the <a title="Memory problems page" href="https://www.eurekalog.com/help/eurekalog/memory_leaks_page.php">"Enable extended memory manager" option</a>.</li>
</ol>
<p>&nbsp;</p>
<h3>E). Out of memory.</h3>
<p>You have out of memory error, but it is not because of EurekaLog's overhead. For example, your application allocates 1.8 Gb of memory and runs just fine, but if you add large enough code to your application (not just EurekaLog, any code of a sufficient size) - your application may not fit inside 2.0 Gb. If this is the case, you have no other choice but to decrease memory footprint of your application.</p>
<ol>
<li>Enable the "large address aware" PE flag, which will give your 32-bit app an extra 1 Gb of memory on 32-bit systems and extra 2 Gb of memory on 64-bit systems:<ol>
<li>You can use "Project" / "Options" menu to open project's options, then enable the "Building" / "Delphi Compiler" / "Linking" / "Enable large addresses" option on modern IDEs;</li>
<li>You can add&nbsp;<span><span style="font-family: &quot;courier new&quot;, courier;">{$LARGEADDRESSAWARE ON}</span>&nbsp;directive on modern IDEs;</span></li>
<li>You can add the&nbsp;<span><span style="font-family: &quot;courier new&quot;, courier;">{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}</span>&nbsp;directive if your IDE does not support <span style="font-family: &quot;courier new&quot;, courier;">{$LARGEADDRESSAWARE ON}</span></span>&nbsp;(don't forget to include the <span style="font-family: &quot;courier new&quot;, courier;">Windows</span> unit for the declaration of the&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">IMAGE_FILE_LARGE_ADDRESS_AWARE</span>).</li>
</ol></li>
<li>Ensure the <a title="Memory problems page" href="https://www.eurekalog.com/help/eurekalog/memory_leaks_page.php">"Reserve lower memory" option</a> is turned off.</li>
<li>Use a memory profiler to find what is occupying most of your memory. Start with largest ones.</li>
<li>Do not load all information into memory at the same time. Load necessary information only when required and unload immediately after use. For example, do not use auto-create forms, create forms on demand. Pay attention to scopes of your objects and things with automatic reference counting (strings, arrays, interfaces, etc.).</li>
<li>Try to offload large information blocks into files or database. For example, giant arrays should be converted to database.</li>
<li>You may try to execute memory hungry tasks in stanalone processes, designed only to run this specific task and nothing else.</li>
<li>Offload large resources from executable into standalone files or a database.&nbsp;Smaller executables will occupy less address space.&nbsp;</li>
<li>If you are using background threads: consider doing things in sequence rather than at the same time.</li>
<li>Review your code for memory optimization. For example:<ol>
<li>Check compiler's optimizations;&nbsp;</li>
<li>Review your code for duplicates. Pay attention to generics to avoid blowing up your code.&nbsp;Smaller executables will occupy less address space;</li>
<li>Check usage of <span style="font-family: &quot;courier new&quot;, courier;">virtual</span> functions. Ensure your application will not be dragging unnecessary code that is never called;</li>
<li>Use algorithms with lower memory usage;</li>
<li>A missing <span style="font-family: &quot;courier new&quot;, courier;">const</span> in arguments could cause unneccessary copying;</li>
<li>Use smallest possible data types and pack everything in records (however, this will probably make your application slower);</li>
<li>Check if you have too much function inlining in your code.</li>
</ol></li>
<li>If you have out of memory error because of a 3rd party code - try to find what specific code actually allocates that much memory.&nbsp;</li>
</ol>
<p>Finally, you can switch to the 64-bit.</p>
<p>&nbsp;</p>
<p>See also:</p>
<ul>
<li><span><a title="My application runs (very) slowly with EurekaLog" href="https://support.eurekalog.com/Knowledgebase/Article/View/92/0/7x-my-application-runs-very-slowly-with-eurekalog">My application runs (very) slowly with EurekaLog</a></span></li>
<li><a title="How to enable/disable EurekaLog at run-time?" href="https://www.eurekalog.com/help/eurekalog/how_to_enable_disable_eurekalog_runtime.php">How to enable/disable EurekaLog at run-time?</a></li>
<li><a title="How to enable EurekaLog for production, disable for development?" href="https://www.eurekalog.com/help/eurekalog/how_to_disable_for_development.php">How to enable EurekaLog for production, disable for development?</a></li>
<li><a title="How to use different settings for development/production?" href="https://www.eurekalog.com/help/eurekalog/how_to_use_different_settings.php">How to use different settings for development/production?</a></li>
</ul>]]></content:encoded>
</item>
<item>
<title><![CDATA[6.x: Mem-leaks is not working on Win2k SP4 with AVG and/or certain patch]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/1]]></link>
<guid isPermaLink="false"><![CDATA[c4ca4238a0b923820dcc509a6f75849b]]></guid>
<pubDate><![CDATA[Tue, 10 Mar 2009 09:03:24 +0000]]></pubDate>
<dc:creator><![CDATA[Alexander Alexeev]]></dc:creator>
<description><![CDATA[Problem:
The mem-leaks feature is not working properly.
 Solution:
The problem is installation of AVG anti-virus system. AVG did not support Win2K SP4 and required an patch from the Microsoft site. After patch installation the mem-leak feature is not w...]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>The mem-leaks feature is not working properly.</p>
<h2><br /> <strong>Solution:</strong></h2>
<p>The problem is installation of AVG anti-virus system. AVG did not support Win2K SP4 and required an patch from the Microsoft site.<br /> After patch installation the mem-leak feature is not working.</p>
<h2><br /> <strong>Remarks:</strong></h2>
<p><strong></strong>This case requires furhter investigating. If you have the similar issue - please, contact our support.<br /> <br /> Checked EL version: 6.0.18<br /> Ticket ID: 231</p>]]></content:encoded>
</item>
<item>
<title><![CDATA[6.x: How to register an expected memory leak?]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/31]]></link>
<guid isPermaLink="false"><![CDATA[c16a5320fa475530d9583c34fd356ef5]]></guid>
<pubDate><![CDATA[Mon, 31 Oct 2011 11:27:28 +0000]]></pubDate>
<dc:creator><![CDATA[Alexander Alexeev]]></dc:creator>
<description><![CDATA[EurekaLog 6 doesn't have any pre-defined RegisterExpectedLeak-like function, but you can do this by using such code: 
uses  ELeaks;
var  EurekaLogAddLeak: procedure(const LeakType: AnsiString; LeakSize, LeakCount: DWord; LeakCallStack: TRawCallStack);
...]]></description>
<content:encoded><![CDATA[EurekaLog 6 doesn't have any pre-defined <span style="font-family: &quot;courier new&quot;, courier;">RegisterExpectedLeak</span>-like function, but you can do this by using such code:<br /> <br />
<pre><strong><span style="font-family: &quot;courier new&quot;, courier;">uses</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">  ELeaks;</span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">
var</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">  EurekaLogAddLeak: <strong>procedure</strong>(<strong>const </strong>LeakType: AnsiString; LeakSize, LeakCount: DWord; LeakCallStack: TRawCallStack);</span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>
procedure </strong>My_Internal_AddLeak(const LeakType: AnsiString; LeakSize, LeakCount: DWord; LeakCallStack: TRawCallStack);</span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">begin</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>  if </strong>{ this is unwanted leak } <strong>then</strong></span><br /><span style="font-family: &quot;courier new&quot;, courier;">    Exit;</span><br /><span style="font-family: &quot;courier new&quot;, courier;">
  EurekaLogAddLeak(LeakType, LeakSize, LeakCount, LeakCallStack);</span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>end</strong>;</span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">
initialization</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">  EurekaLogAddLeak := AddLeak;</span><br /><span style="font-family: &quot;courier new&quot;, courier;">  AddLeak := My_Internal_AddLeak;</span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>end</strong>.</span></pre>
<p>&nbsp;</p>
<p>In order to identify leak - you can analyze passed arguments (for leak type, leak size and leak call stack).<br /> <br /> Call stack is array of RAW addresses of fixed size. Start with 0 and loop though <span style="font-family: &quot;courier new&quot;, courier;">High(LeakCallStack)</span>, stop once encounter 0 address.<br /> <br /> You can also get a textual description of each address by using <span style="font-family: &quot;courier new&quot;, courier;">GetSourceInfoByAddr</span> function:</p>
<pre><strong><span style="font-family: &quot;courier new&quot;, courier;">var</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">  DebugInfo: TEurekaDebugInfo;</span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">begin</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">  // walk through call stack or just pick first item - your choice </span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>  for </strong>n := 0 <strong>to </strong>High(LeakCallStack) - 1 <strong>do   </strong></span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">  begin  </span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>    if </strong>LeakCallStack[n] = 0 <strong>then  </strong></span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>      Break</strong>;  </span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>    if </strong>GetSourceInfoByAddr(LeakCallStack[n], @DebugInfo) <strong>then</strong></span><br /><span style="font-family: &quot;courier new&quot;, courier;">      // DebugInfo contains description of LeakCallStack[n]</span><br /><strong><span style="font-family: &quot;courier new&quot;, courier;">    else</span></strong><br /><span style="font-family: &quot;courier new&quot;, courier;">      // Only RAW address is available</span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>  end</strong>;</span><br /><span style="font-family: &quot;courier new&quot;, courier;"><strong>end</strong>;</span></pre>]]></content:encoded>
</item>
<item>
<title><![CDATA[7.x: Memory leak after sending bug report with Mantis]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/61]]></link>
<guid isPermaLink="false"><![CDATA[7f39f8317fbdb1988ef4c628eba02591]]></guid>
<pubDate><![CDATA[Mon, 11 Mar 2013 15:53:19 +0000]]></pubDate>
<dc:creator />
<description><![CDATA[Problem:
I get error report about multiple leaks after using sending with Mantis send method. There is no leak report if I don't click on "Send report".
Reason:
It's a bug in Delphi's SOAP implementation.
Solution:

Use the latest RAD Studio version which...]]></description>
<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>I get error report about multiple leaks after using sending with Mantis send method. There is no leak report if I don't click on "Send report".</p>
<p><strong>Reason:</strong></p>
<p><strong></strong>It's a <a title="QC: Report #91160" href="http://qc.embarcadero.com/wc/qcmain.aspx?d=91160" target="_blank">bug in Delphi's SOAP implementation</a>.</p>
<p><strong>Solution:</strong></p>
<ol>
<li>Use the latest RAD Studio version which fixes this bug.</li>
<li>Manually edit&nbsp;<span>WSDLLookup.pas file and recompile it. Recompile EurekaLog to use new file (this will require EurekaLog Enterprise edition with full source code).</span></li>
</ol>
<p><strong>Update:</strong>&nbsp;</p>
<p>Use latest EurekaLog version, we are not using Delphi's SOAP implementation anymore.</p>
<ol> </ol>]]></content:encoded>
</item>
<item>
<title><![CDATA[7.x: [C++ Builder] I get &quot;Abnormal program termination&quot; or other type of crash a...]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/73]]></link>
<guid isPermaLink="false"><![CDATA[d2ddea18f00665ce8623e36bd4e3c7c5]]></guid>
<pubDate><![CDATA[Tue, 30 May 2017 11:50:15 +0000]]></pubDate>
<dc:creator />
<description><![CDATA[Problem:
Even empty C++ Builder application crashes with&nbsp;"Abnormal program termination" or system crash dialog at exit.
Explanation:
Your project has memory or resource checks enabled. However, you did not configured your project correctly. Memory/re...]]></description>
<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Even empty C++ Builder application crashes with&nbsp;"Abnormal program termination" or system crash dialog at exit.</p>
<p><strong>Explanation:</strong></p>
<p>Your project has memory or resource checks enabled. However, you did not configured your project correctly. Memory/resource finalization calls are in the wrong order.</p>
<p><strong>Solution:</strong></p>
<p>You can either:</p>
<p>a). Disable <a title="Memory problems page" href="http://www.eurekalog.com/help/eurekalog/memory_leaks_page.php" target="_blank">memory</a> <strong>and</strong> <a title="Resource leaks page" href="http://www.eurekalog.com/help/eurekalog/resource_leaks_page.php" target="_blank">resource</a> checks;</p>
<p>or</p>
<p>b). <a title="Enabling memory/resource leaks features for C++ Builder" href="http://www.eurekalog.com/help/eurekalog/enabling_memory_features.php" target="_blank">Configure initialization order of your project</a>.</p>
<p><strong>See also:</strong></p>
<ul>
<li><a title="KB Article: 7.x: Leaks in empty C++ Builder application" href="https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/75/1/7x-leaks-in-empty-c-builder-application">Leaks in empty C++ Builder application</a></li>
</ul>]]></content:encoded>
</item>
<item>
<title><![CDATA[7.x: Leaks in empty C++ Builder application]]></title>
<link><![CDATA[https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/75]]></link>
<guid isPermaLink="false"><![CDATA[d09bf41544a3365a46c9077ebb5e35c3]]></guid>
<pubDate><![CDATA[Mon, 17 Dec 2018 11:33:41 +0000]]></pubDate>
<dc:creator />
<description><![CDATA[Problem:
I receive leak reports from EurekaLog in a blank empty VCL application.
Reason:

You did not set up your project properly, so EurekaLog's leak checking code is running too early.
You may see technical leaks. See below for an example.

Example (te...]]></description>
<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>I receive leak reports from EurekaLog in a blank empty VCL application.</p>
<p><strong>Reason:</strong></p>
<ol>
<li>You did not set up your project properly, so EurekaLog's leak checking code is running too early.</li>
<li>You may see technical leaks. See below for an example.</li>
</ol>
<p><strong>Example (technical leak):</strong></p>
<ol>
<li> When application exits: RTL enters shutdown cycle inside <span style="font-family: &quot;courier new&quot;, courier;">_cleanup()</span> routine from <span style="font-family: &quot;courier new&quot;, courier;">initexit.c</span> file. This routine will call any registered finalization subroutine (e.g. exit procedure), such as EurekaLog and I/O streams finalization. </li>
<li>C++ RTL will flush opened streams during shutdown (<span style="font-family: &quot;courier new&quot;, courier;">fflush()</span> routine from <span style="font-family: &quot;courier new&quot;, courier;">fflush.c</span> file is called from <span style="font-family: &quot;courier new&quot;, courier;">_exit_streams()</span> finalization routine from <span style="font-family: &quot;courier new&quot;, courier;">streams.c</span> file).</li>
<li>Unfortunately, flushing stream will keep an allocated memory block used for stream locking (lock is allocated from <span style="font-family: &quot;courier new&quot;, courier;">_lock_stream()</span> from <span style="font-family: &quot;courier new&quot;, courier;">streams.c</span>).</li>
<li>This memory block will remain alive, even when other code (including EurekaLog) cleanup (inside cleanup cycle in the <span style="font-family: &quot;courier new&quot;, courier;">_cleanup()</span> routine).</li>
<li>EurekaLog will detect memory block that was allocated, but not freed. EurekaLog will report this block as leak.</li>
<li>Once EurekaLog (and other code) finishes shutdown - RTL will continue to cleanup.</li>
<li>RTL will delete allocated locks by calling <span style="font-family: &quot;courier new&quot;, courier;">_cleanup_handle_locks()</span> and <span style="font-family: &quot;courier new&quot;, courier;">_cleanup_stream_locks()</span>&nbsp;(after <span style="font-family: &quot;courier new&quot;, courier;">_cleanup()</span> routine completes) and terminate the process.</li>
</ol>
<p><strong>Solution:</strong>&nbsp;</p>
<ol>
<li>Follow <a title="EurekaLog Help: Enabling memory/resource leaks features for C++ Builder" href="https://www.eurekalog.com/help/eurekalog/enabling_memory_features.php">our guidelines</a> for setting up your project for leak reporting. Basically, you need to ensure that EurekaLog's code is initialized first and finalized last. Otherwise, EurekaLog's leak checking code will run when there are unallocated resources. Such resources will be reported as leaks, even though it is finalized later.</li>
<li>Ignore technical leaks. You may try to <a title="EurekaLog Help: How to ignore a leak?" href="https://www.eurekalog.com/help/eurekalog/how_to_ignore_leak.php">add such leaks as expected leaks</a>. Or you may try to cleanup such leaks manually before execution of EurekaLog's leaks checking. E.g. calling routines such as&nbsp;<span style="font-family: &quot;courier new&quot;, courier;">_cleanup_stream_locks()</span> at shutdown. But this may not always be possible.</li>
</ol>
<p><strong>See also:</strong></p>
<ul>
<li><a title="KB Article: 7.x: [C++ Builder] I get &quot;Abnormal program termination&quot; or other type of crash at shutdown" href="https://support.eurekalog.com/index.php?/Knowledgebase/Article/View/73/1/7x-c-builder-i-get-abnormal-program-termination-or-other-type-of-crash-at-shutdown">I get "Abnormal program termination" or other type of crash at shutdown</a></li>
</ul>
<ol> </ol>]]></content:encoded>
</item>
</channel>
</rss>