memory leak

G

GJ

Hi,

Can we trace a memory leak in a C++ program without using any specific tools
like purifier.
 
A

Alf P. Steinbach

* GJ:
Can we trace a memory leak in a C++ program without using any specific tools
like purifier.

It's a lot easier to use appropriate tools, so why not?

Otherwise you'll have to instrument your whole application, i.e. recompile
with 'new' replaced with something that keeps track of where and when. A
simple replacement of global operator new can't do that because it doesn't
know. So we're then talking about e.g. #define new as something else, as was
done in e.g. old MFC (with disastrous consequences, they forgot to redefine
delete accordingly, which meant a debug build would leak memory if any
constructor threw an exception).
 
M

mlimber

Alf said:
* GJ:

It's a lot easier to use appropriate tools, so why not?

Otherwise you'll have to instrument your whole application, i.e. recompile
with 'new' replaced with something that keeps track of where and when. A
simple replacement of global operator new can't do that because it doesn't
know. So we're then talking about e.g. #define new as something else, as was
done in e.g. old MFC (with disastrous consequences, they forgot to redefine
delete accordingly, which meant a debug build would leak memory if any
constructor threw an exception).

Alf, Could you please define "old MFC" in terms of Visual C++ version?

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,590
Members
45,100
Latest member
MelodeeFaj
Top