469,902 Members | 1,939 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

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 2452
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by eyh5 | last post: by
20 posts views Thread by jeevankodali | last post: by
13 posts views Thread by Boni | last post: by
30 posts views Thread by MAG1301 | last post: by
24 posts views Thread by c language | last post: by
20 posts views Thread by gNash | last post: by
22 posts views Thread by Peter | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.