<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NeoEGM.com &#187; Debug</title>
	<atom:link href="http://www.neoegm.com/tag/debug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neoegm.com</link>
	<description>Knowledge is inside</description>
	<lastBuildDate>Mon, 08 Jul 2024 05:38:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>cMemDbg &#8211; Easy to use C memory leak detection library</title>
		<link>http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/</link>
		<comments>http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 18:42:07 +0000</pubDate>
		<dc:creator><![CDATA[NeoEGM]]></dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Easy]]></category>
		<category><![CDATA[Freeware]]></category>
		<category><![CDATA[GNU GPL]]></category>
		<category><![CDATA[Include]]></category>
		<category><![CDATA[Library]]></category>
		<category><![CDATA[Memory Leaks]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.neoegm.com/?p=58</guid>
		<description><![CDATA[After some time working with C, I decided to develop a very easy to use library which can help you to detect and track memory leaks. There are lots of solutions for this on the net, but this one has the particularity of being really simple to implement. You just have to add the following [&#8230;]<div class='yarpp-related-rss'>
<strong>
Related posts:<ol>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cppmemdbg-easy-to-use-cpp-memory-leak-detection-library/" rel="bookmark" title="cppMemDbg &#8211; Easy to use C++ memory leak detection library">cppMemDbg &#8211; Easy to use C++ memory leak detection library </a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/simple-list-class/" rel="bookmark" title="Simple C++ List Class">Simple C++ List Class </a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/simple-string-class/" rel="bookmark" title="Simple C++ String Class">Simple C++ String Class </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>After some time working with C, I decided to develop a very easy to use library which can help you to detect and track memory leaks.</p>
<p>There are lots of solutions for this on the net, but this one has the particularity of being really simple to implement.</p>
<p><span id="more-58"></span><br />
You just have to add the following include to your main include file (a file that gets included by each file of your project) or, in case you don&#8217;t have one, to each file that calls any memory allocation function (malloc, realloc, calloc or free). The only extra caution you have to take into account is to include it <strong>after</strong> the standard headers (stdio.h, stdlib.h, malloc.h, etc.).</p>
<p>This is the line:</p>
<pre class="brush: plain; light: true; title: ; notranslate">#include &quot;cMemDbg.h&quot;</pre>
<p>That&#8217;s all&#8230; Expecting more? Well, there is a final step&#8230; You have to make this call just before you exit your program so you can get the detailed conclusions:</p>
<pre class="brush: plain; light: true; title: ; notranslate">PrintMemoryLeakInfo();</pre>
<p>Easy, not?</p>
<p>That was all&#8230; Really.</p>
<p>Now, before going to more &#8220;expert&#8221; features, I&#8217;ll leave here the link to download the library for the ones who don&#8217;t wish to keep reading:</p>
<div align="center">
<p class="download"><a href="http://download.neoegm.com/software/cmemdbg/cMemDbg_1.0.zip">Download cMemDbg 1.0</a></p>
</div>
<p>Now let&#8217;s continue&#8230;</p>
<p>The library comes with three configurable settings (available in cMemDbg.c):</p>
<ul>
<li><strong>PRINT_OPERATIONS:</strong> If set to 1, it will print to the configured output (stdout by default) each memory alloc operation done in the program (allocation or free). Otherwise, the library will just print problems and notifications and the final dump. <em>[Default value = 1]</em></li>
<li><strong>MAX_ALLOC:</strong> Internal library memory stack length (in elements). It is the max amount of allocations that can be tracked without being freed. You can increase this value at will if needed. In fact, if it is needed, the library will print a message saying: &#8220;INTERNAL_ERROR: Allocation stack overflow, please increase MAX_ALLOC&#8221;. <em>[Default value = 256]</em></li>
<li><strong>PRINT_OUTPUT:</strong> Location to print the library generated notifications (can be any stream/file in which you could print using fprintf). <em>[Default value = stdout]</em></li>
</ul>
<p>Finally, there are two more functions you could use wherever needed:</p>
<ul>
<li><strong>PrintTotalAllocatedMemory():</strong> Prints the accumulative amount of memory allocated at the moment of the call.</li>
<li><strong>PrintMemoryReservedByCMemDbgLibrary():</strong> Prints the amount of memory reserved by the library (defined at compilation time by the MAX_ALLOC constant).</li>
</ul>
<p>That&#8217;s all&#8230; I said it was easy to use.</p>
<p>Anyway, if after reading the cMemDbg.h files&#8217; comments, you have any questions, comments or suggestions, please feel free to contact me.<br />
<h4>Incoming search terms for the article:</h4>
<ul>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="detectar fugas de memoria en c">detectar fugas de memoria en c</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="cmemdbg">cmemdbg</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="c memory leak">c memory leak</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="detectar fuga memoria c">detectar fuga memoria c</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="detectar fugas de memoria">detectar fugas de memoria</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="internal_error allocation stack overflow please increase max_alloc">internal_error allocation stack overflow please increase max_alloc</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="detectar memory leaks c">detectar memory leaks c</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="detectar fugas de memoria c">detectar fugas de memoria c</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="freebsd memory leak detection">freebsd memory leak detection</a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/" title="Detector de fugas de memoria">Detector de fugas de memoria</a></li>
</ul>
<div class='yarpp-related-rss'>
<strong><p>Related posts:<ol>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/cppmemdbg-easy-to-use-cpp-memory-leak-detection-library/" rel="bookmark" title="cppMemDbg &#8211; Easy to use C++ memory leak detection library">cppMemDbg &#8211; Easy to use C++ memory leak detection library </a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/simple-list-class/" rel="bookmark" title="Simple C++ List Class">Simple C++ List Class </a></li>
<li><a href="http://www.neoegm.com/tech/programming/c-cpp/simple-string-class/" rel="bookmark" title="Simple C++ String Class">Simple C++ String Class </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.neoegm.com/tech/programming/c-cpp/cmemdbg-easy-to-use-c-memory-leak-detection-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
