472,796 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 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 2595
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.