[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Sat Sep 25 08:41:19 2004 -->
- <!--x-from-r13: rfbgrevp ng 3gvzrf25.arg (Urbsserl) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: Pine.LNX.4.44.0409241928230.13308-[email protected] -->
- <!--x-reference: [email protected] -->
- <!--x-reference: [email protected]-a-geek.com --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] C++ Debuggery and the Path of Destruction -->
- <li><em>date</em>: Sat Sep 25 08:41:19 2004</li>
- <li><em>from</em>: esoteric at 3times25.net (Geoffrey)</li>
- <li><em>in-reply-to</em>: <<a href="msg00847.html">[email protected]</a>></li>
- <li><em>references</em>: <[email protected]> <<a href="msg00844.html">[email protected]</a>> <<a href="msg00847.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] C++ Debuggery and the Path of Destruction</li>
>> __FILE__::__LINE__ is now creating a __WHATEVER__, address 0xabcddcab
>> __FILE__::__LINE__ is now deleting a __WHATEVER__, address 0xabcddcab
>
>
>
> This is handy. My trick is for each object that has a malloc or new,
> that object is responsible for deleting/free ing the data as well.
> Paired with a counter to keep track of mallocs in each object is handy
> and I tend to catch memory leaks fast:
Excellent points both. What we used to do when we were oft times
allocating memory in many section of code is add some #ifdefs to track
allocation and freeing. Start the output with the memory address so
that one can simply pipe the output to sort and should see matching
allocations/frees:
804845c : allocated, foo.c(345)
804845c : freed, foo.c(345)
The form is:
address : [allocated|freed], __FILE__(__LINE__)
We used #ifdef because we learned that about the time you had it all
figured out and removed the debug code, you started having another
memory leak. :)
--
Until later, Geoffrey Registered Linux User #108567
AT&T Certified UNIX System Programmer - 1995
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00852" href="msg00852.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
<ul><li><em>From:</em> johnmills at speakeasy.net (John Mills)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00843" href="msg00843.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
<ul><li><em>From:</em> johnmills at speakeasy.net (John Mills)</li></ul></li>
<li><strong><a name="00844" href="msg00844.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
<ul><li><em>From:</em> rountree at cs.uga.edu (Barry Rountree)</li></ul></li>
<li><strong><a name="00847" href="msg00847.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
<ul><li><em>From:</em> bjorn at sccs.swarthmore.edu (Bjorn Dittmer-Roche)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00848.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00850.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00847.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00852.html">[ale] C++ Debuggery and the Path of Destruction</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00849"><strong>Date</strong></a></li>
<li><a href="threads.html#00849"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>