Re: PrintScreen & IVideoWindow
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Fri, 21 Apr 2006 17:23:38 -0700
"Alessandro Angeli [MVP::DS/MF]" <nobody@xxxxxxxxxxxxxxxxxx> wrote in
message news:udbyjnZZGHA.3448@xxxxxxxxxxxxxxxxxxxxxxx
offtopic. how to debug such leaks ?
The guys here suggest to use smart COM pointers to avoid reference leaks
to begin with.
As we have seen from previous posts, the "smart" COM pointers don't
eliminate leaks, nor guarantee avoidance of other problems. They are
helpful, especially for programmers who don't have practice being very
detailed about their references. But they aren't a panacea.
To the original poster, I had the pleasure (no, really :) ) of implementing
debug code to help track and debug memory leaks in a couple of projects I
used to work on. We already had leak-detection code, but it was a royal
pain trying to figure where the memory had been allocated (even when you
could tell what the memory held), never mind who should have freed it.
I added a header to the custom-allocated memory blocks in which I stored the
last six return addresses from the stack. This was a while ago, and I had
to write the code to walk the stack by hand; we deciphered the addresses
simply by having the debugger disassemble the code at the address (it would
display the symbol corresponding to the address in the dump...I was too lazy
to add code to grab the symbol table and do the look-up automatically :) )).
Of course, these days you have tools like DbgHelp to do the heavy-lifting
for you. For all I know, it'll walk the stack for you too (don't
know...haven't looked at it recently).
Even if you do everything by hand, it's not that hard to implement. And the
ease with which debugging memory leaks becomes is invaluable. I don't know
why this sort of functionality isn't built into the debug libraries already.
The need has existed ever since the first programmer allocated a block of
memory, and with all the strides development environments have made over the
years, it amazes me that it's always still a mystery where a leaked block of
memory came from.
I suppose these days it might take more than six stack frames to reliably
know why a block was allocated and who should have freed it. But there's a
lot more RAM to play with too. Whatever, the basic idea is sound and I can
speak from personal experience to say that it really helps.
Pete
.
- Follow-Ups:
- Re: PrintScreen & IVideoWindow
- From: Alessandro Angeli [MVP::DS/MF]
- Re: PrintScreen & IVideoWindow
- References:
- PrintScreen & IVideoWindow
- From: Tulup
- Re: PrintScreen & IVideoWindow
- From: Tulup
- Re: PrintScreen & IVideoWindow
- From: Alessandro Angeli [MVP::DS/MF]
- Re: PrintScreen & IVideoWindow
- From: Tulup
- Re: PrintScreen & IVideoWindow
- From: Alessandro Angeli [MVP::DS/MF]
- Re: PrintScreen & IVideoWindow
- From: Tulup
- Re: PrintScreen & IVideoWindow
- From: Alessandro Angeli [MVP::DS/MF]
- Re: PrintScreen & IVideoWindow
- From: Tulup
- Re: PrintScreen & IVideoWindow
- From: Alessandro Angeli [MVP::DS/MF]
- PrintScreen & IVideoWindow
- Prev by Date: Re: PrintScreen & IVideoWindow
- Next by Date: Re: PrintScreen & IVideoWindow
- Previous by thread: Re: PrintScreen & IVideoWindow
- Next by thread: Re: PrintScreen & IVideoWindow
- Index(es):
Relevant Pages
|