473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Detecting memory leaks

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
Jul 18 '05 #1
2 1843
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.

Jul 18 '05 #2
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-
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Maurice | last post by:
Hi there, I'm experiencing big memory problems on my webserver. First on an old RedHat 7.2 system, now on an other fresh installed Suse 8.2 system: Linux version 2.4.20-4GB...
2
by: barkha shah | last post by:
Hi , Can any one please suggest me the memory Leak detecting tool in Visual Studio.Net 2003 Release version Framework. Can I use Numega Bounds checker for this. Thanks and Regards. barkha
0
by: Steve Binney | last post by:
My code makes synchronous HttpWebRequest and HttpRebResponse calls. In VS 2003, I am getting memory leaks and event handle leaks. I am closing all streams and using "using"statements. I have...
2
by: Generic Usenet Account | last post by:
I have been using STL for a long time now, without any problems. Recently we generated a purification report on our software using Rational Purify, and we found some memory leaks. My colleague...
2
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is...
2
by: JerryK | last post by:
Hi, We have a complex application that is experiencing a "memory leak". This is not a traditional memory, since the application gives all the memory back at terminate. Rather what we see i...
4
by: Diego Martins | last post by:
Hi all! I am doing a crude investigation of memory leaks in objects created by external libraries. Since I don't have access to the source code, I can't tell if an object are freeing its resources...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
16
by: graham.keellings | last post by:
hi, I'm looking for an open source memory pool. It's for use on an embedded system, if that makes any difference. Something with garbage collection/defragmentation would be nice. It should have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.