Re: How to detect and remove memory leak?



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
----------------------------------------------------------------------

.



Relevant Pages

  • Urgent: How to find memory leaks? -- profiler???
    ... I'm using some APIs to create registry keys, then report some events ... to windows event viewer.Now my program runs from command prompt, ... but my program seems to have memory leaks. ...
    (microsoft.public.vb.winapi)
  • How to detect and remove memory leak?
    ... I'm using some APIs to create registry keys, then report some events ... to windows event viewer.Now my program runs from command prompt, ... but my program seems to have memory leaks. ...
    (microsoft.public.vb.winapi)
  • Re: dll trouble - final status
    ... | Just to give you a final report. ... | I am giving up the idea of connecting fortran and VB, ... | W98 is rather slow, but I am seriously thinking to replace XP with W98 on ... FPS4 is notorious for memory leaks. ...
    (comp.lang.fortran)
  • Re: Fastcode MM memory usage
    ... Good suggestion. ... {Set this option to enable reporting of memory leaks. ... {Set this option to require the presence of the Delphi IDE to report memory ... This option has no effect if the option "EnableMemoryLeakReporting" ...
    (borland.public.delphi.language.basm)

Quantcast