Re: memory leak?
- From: wanwan <ericwan78@xxxxxxxxx>
- Date: Fri, 27 Jul 2007 21:33:51 -0000
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
.
- Follow-Ups:
- Re: memory leak?
- From: Doug Harrison [MVP]
- Re: memory leak?
- From: Scott McPhillips [MVP]
- Re: memory leak?
- References:
- memory leak?
- From: wanwan
- Re: memory leak?
- From: Joseph M . Newcomer
- Re: memory leak?
- From: Doug Harrison [MVP]
- memory leak?
- Prev by Date: Re: Ownerdraw CListBox - don't get it
- Next by Date: Re: memory leak?
- Previous by thread: Re: memory leak?
- Next by thread: Re: memory leak?
- Index(es):
Relevant Pages
|
Loading