Re: memory leak?



On Jul 27, 2:39 pm, "Doug Harrison [MVP]" <d...@xxxxxxxx> wrote:
On Fri, 27 Jul 2007 14:06:18 -0400, Joseph M. Newcomer

<newco...@xxxxxxxxxxxx> wrote:
It depends on what you mean by "near the exit of the program". The C debug runtime does
its check for memory leaks before static destructors are called, and I'm not sure where it
fits with respect to ExitInstance, but your report might be spurious. Without knowing the
details of where you put it, though, it is hard to tell.
joe

Minor correction: It's MFC that dumps leaks too early and routinely causes
spurious leak reports. The CRT dumps leaks after static duration objects
have been destroyed, which is the only correct "end-of-program time" to do
it.

--
Doug Harrison
Visual C++ MVP

I further tested my application after posting the message.

I ran my program is debug mode. I marked a breakpoint at the line
free(myPtr). I found out after stepping over the line, myPtr was still
pointing at a memory location. So free() had no effect on myPtr.

One thing to note is that in my program, I used another pointer
variable to allocate memory. Later on, the block of memory was passed
to myPtr as a pointer. Is there a rule that requires me to free memory
with the same pointer variable as the one I use to allocate memory? It
looks like the case to me.

Please confirm

.



Relevant Pages

  • Re: MDAC memory leak
    ... when the storage should be freed. ...  Most libraries place the decision of when to free ... strcore leaks are hard to diagnose, because they mean you have an unfreed CString. ... There's a capability of breaking on a particular memory allocation, ...
    (microsoft.public.vc.mfc)
  • Re: MDAC memory leak
    ... when the storage should be freed. ...  Most libraries place the decision of when to free ... strcore leaks are hard to diagnose, because they mean you have an unfreed CString. ... There's a capability of breaking on a particular memory allocation, ...
    (microsoft.public.vc.mfc)
  • Re: tip50 Accepted
    ... This is also the version to be bundled with Tcl core 8.6 beta. ... Is it really true that memory leaks are being plugged in code which is ... It is really unbelievable that a developer would be hunting down ...
    (comp.lang.tcl)
  • Re: tip50 Accepted
    ... This is also the version to be bundled with Tcl core 8.6 beta. ... Is it really true that memory leaks are being plugged in code which is ...
    (comp.lang.tcl)
  • Re: FastMM 4.40 released (replacement memory manager for Delphi IDE and applications, free and open
    ... >> A fast replacement memory manager for Borland Delphi Win32 applications ... >> - Optionally reports memory leaks on program shutdown. ... >> the need for stack frames. ... If exception handling is not in place FastMM ...
    (borland.public.delphi.thirdpartytools.general)

Loading