Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Detecting memory leaks

Reply
Thread Tools

Detecting memory leaks

 
 
Jive
Guest
Posts: n/a
 
      11-21-2004
The short form of the question is, how can I trace memory usage (preferably
from C) with an eye toward finding out if I'm leaking memory?

I would have thought there would be a ton of info on this, but I've been
googling for half and hour and I keep coming up empty.

I've recently ported Python to a realtime operating system, and I've
implemented a small C extension module. The system controls a piece of
equipment. A test program runs for about a week and then crashes. The
first thing I think of to eliminate is the possibility of a memory leak.

I would also welcome a list of common causes of infant mortality in new
ports and extensions.

jdadson at yahoo dott com


 
Reply With Quote
 
 
 
 
bowman
Guest
Posts: n/a
 
      11-21-2004
Jive wrote:

> The short form of the question is, how can I trace memory usage
> (preferably from C) with an eye toward finding out if I'm leaking memory?


Have you looked at efence or dmalloc? I don't know if either could be ported
to your RTOS. efence depends on the hardware and both make assumptions on
the memory allocation schemes.

 
Reply With Quote
 
 
 
 
Eddie Parker
Guest
Posts: n/a
 
      11-21-2004

>Jive wrote:
>
>
>
>>The short form of the question is, how can I trace memory usage
>>(preferably from C) with an eye toward finding out if I'm leaking memory?
>>
>>


If you're interested in a 'poor-mans' solution, or rather a
"not-built-here" solution, you could do something like the following:

(in debug)

1) Override all new and deletes
2) Have new add to a linked list, placing __FILE__, __LINE__ and a
pointer to the memory created
3) Have delete remove from said linked list
4) Have another call that displays the linked list's contents out.

Then, simply have the call that displays the linked lists contents
execute whenever you believe you should have all the objects deleted.

I realize this could fail for a variety of reasons:
a) Some(/all?) parts of your code don't use new and delete
b) You want to detect memory leaks in an environment where you still
have *some* items newed
c) I missed the point completely and gave poor advice.

Anyways, I'm not sure if this will help, but it's what I use in my apps.
Apologies if it doesn't!

-e-
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting memory leaks using _CrtDumpMemoryLeaks lancer6238@yahoo.com C Programming 5 04-09-2012 03:25 AM
Detecting memory leaks on apache, mod_python Ilias Lazaridis Python 14 12-23-2007 09:25 AM
searching a function of standard libraries to help detecting memory leaks Diego Martins C++ 4 10-09-2006 05:46 PM
ASP.NET - Detecting memory leaks ASP.Confused ASP .Net 2 07-16-2004 04:24 PM
detecting memory leaks in Perl Jerome Sui Perl Misc 0 07-13-2003 02:37 PM



Advertisments