Re: How to detect and remove memory leak?
- From: "Thorsten Albers" <albersRE@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Jun 2005 03:59:12 -0700
Sachin_M <SachinM@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Beitrag
<AC56CE43-EBA6-42E2-8207-0C29D7D194D7@xxxxxxxxxxxxx>...
> I'm using some APIs to create registry keys, then report some events
> to windows event viewer.Now my program runs from command prompt, there is
no
> UI (no dialogs).And it is programmed to log events unless terminated
> exclusively.
> but my program seems to have memory leaks. That I've got from Task
Manager.
> How to detect these memory leaks?
> I've heard of some profilers which reports where is the error. Have
downloaded
> AQTime. But don't have time to go through it.
> Can somebody help me how to find which function/module is dumping the
memory?
> I need a simple tool, easy to configure and should point out where the
problem
> is....
The best profiler for this aim you can find is you yourself...
Memory leaks are not a problem of the system or of somebody else but only
of your own code (and in addition maybe of some third party code referenced
in your project - where usually you can't do anything to avoid it).
There are some simple rules to avoid memory leaks:
b) Reselect >always< the original objects into e.g. device contexts.
a) Destroy >every< GDI object you have created unless the MSDN
documentation states explicitely that you don't have to do so.
b) Free >all< memory you have allocated unless the MSDN documentation
states explicitely that you don't have to do so.
c) Don't used the VB statement "End"
d) Use global variables only were they really can't be avoided. Often
global variables are the reason for the developer to have lost control of
his code.
For a) and b) it is essentially important that you are tracking the way of
all GDI object handles and allocated memory handles, so that you don't get
lost of a handle before you have destroyed the respective object or freed
the respective memory.
--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
.
- References:
- How to detect and remove memory leak?
- From: Sachin_M
- How to detect and remove memory leak?
- Prev by Date: Re: DOS-Path
- Next by Date: Re: System resources when drawing outside bitmap
- Previous by thread: Re: How to detect and remove memory leak?
- Next by thread: How to send a mail from app, without blocking APP!?
- Index(es):
Relevant Pages
|