473,320 Members | 1,881 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,320 software developers and data experts.

How to check memory leak in C/C++ programs?

Hi,
I am writing some hybrid application s using C/C++ modules
together....Here I have created and used a lot of malloc(...) and
new(...) operators.

I am interested in checking on the optimisation part of the
programs...like memory consumed,memory leak , processor utilisation and
like...most of the info I got from task manager...however still I cand
find way to check on memory leaks...

Suggestions required on some good procedures or tools..

Thanks in advance,
a.a.cpp :-)

Jul 23 '05 #1
5 2621
Try using boehm-gc garbage collector, valgrind and some other malloc
libraries.

Jul 23 '05 #2
On 2005-05-13, iceColdFire <ic*******@yahoo.com> wrote:
Hi,
I am writing some hybrid application s using C/C++ modules
together....Here I have created and used a lot of malloc(...) and
new(...) operators.

I am interested in checking on the optimisation part of the
programs...like memory consumed,memory leak , processor utilisation and
like...most of the info I got from task manager...however still I cand
find way to check on memory leaks...

Suggestions required on some good procedures or tools..


There are a number of leak checkers. A simple way to roll your own is to
overload operator new and that way you track allocations. Another way is
to get a leak checker. For example, there is a tool called ccmalloc that
tracks memory allocations and leaks. There are other more sophisticated
tools that also check for buffer overruns, etc.

For things like CPU usage, you probably should look for some sort of profiling
tool. These will track how much time different functions use, so you know
where you need to optimise.

Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
Jul 23 '05 #3

iceColdFire wrote:
Hi,
I am writing some hybrid application s using C/C++ modules
together....Here I have created and used a lot of malloc(...) and
new(...) operators.

I am interested in checking on the optimisation part of the
programs...like memory consumed,memory leak , processor utilisation and like...most of the info I got from task manager...however still I cand find way to check on memory leaks...

Suggestions required on some good procedures or tools..

Thanks in advance,
a.a.cpp :-)


Check out the following links:
http://code.axter.com/debugalloc.cpp
http://code.axter.com/debugalloc.h

http://code.axter.com/debuglogger.cpp
http://code.axter.com/debuglogger.h

http://code.axter.com/debuglog.c
http://code.axter.com/debuglog.h

The debugalloc.* code has the ability to track memory leaks, and it has
description and usage information in comments.

The debuglogger code has some code for profileing your code.

And the debuglog is some limited C version of the code.

It's mostly portable.

If you're programming using VC++, you should look up _CrtCheckMemory
and assoicated functions.

Jul 23 '05 #4
:: Thanks Donovan, Axter, Rikrak

I am going through the links and other docs provided by you..

Shall ping this thread again if required...

Thanks again for good suggestions,
+ a.a.cpp :-)

Jul 23 '05 #5
Hi,

Some more good tools ...but *not* for free

Rational Purify -- for memory leaks
Rational Quantify -- for measuring performance
Rational PureCoverage -- for checking the test effectiveness.

-vs_p...

Jul 23 '05 #6

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

Similar topics

10
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
13
by: Boni | last post by:
I use 3-d party component. In this component I must pass a reference to my object. The problem is that this component has an ugly bug.When this component is disposed, it incorrectly don't delete...
30
by: MAG1301 | last post by:
I've detected memory leaks in our huge .NET 1.1 C# application but couldn't localize them directly. So I've reduced the code to the following console application: using System; using System.IO;...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
24
by: c language | last post by:
Hello all, I am using 'Valgrind' to fix the memory leaks of my programs. I am looking for other programs to see how they are detecting the problems. Does any of you have experience in working...
17
by: Mike | last post by:
Hello, I have following existing code. And there is memory leak. Anyone know how to get ride of it? function foo has been used in thousands places, the signature is not allowed to change. ...
20
by: gNash | last post by:
Hi all, void main() { char *fp; fp=malloc(26); strcpy(fp,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); fp='\0'; free(fp); }
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.