I need help with a memory leak that appears to be pointing at an empty constructor. ?

Started by
11 comments, last by Matias Goldberg 13 years, 8 months ago
Quote:Original post by chadsxe
Well,

I think I just figured out my issue. I was making a call like so

ZeroMemory( &sound, sizeof( Sound ) );


As a rule of thumb: never use this to initialize anything, ever, unless (a) it came from the Windows API and (b) the Windows API specifically said you could use ZeroMemory to initialize it.
Advertisement
Hi,

Well that was defiantly the problem I was having. Thanks to all for the info and useful tips.

Regards

Chad
Quote:Original post by jyk
I may just be misunderstanding, but could you clarify this? The absence of an explicit destructor doesn't mean that there is no destructor, nor that associated resources will not be freed (at least those that are able to clean up after themselves, that is). Unless I'm mistaken, there's really no reason to add an empty, non-virtual destructor to a class, as the compiler-generated version should be equivalent (and sufficient).

But maybe you meant something other than that...

My bad. It's been a long time I don't give a totally wrong advice :ashamed:

Well, actually, you're right the compiler should and does generate an implicit destructor.
However I wrote that advice with a similar experience of mine in mind, where I was having a memory leak report pointing at an std::vector in a very simple class being used in a more advanced template class. Stranged because it shouldn't be happening, I made sure the report was happening after all memory was freed, including main()'s stack and global variables. Then I wrote an explicit destructor, and problem goes away. Call it compiler bug (VC 2008 EE), memory corruption, overlooked bug, etc; but that's what happened and that's why I wrote that; thinking it could be a similar problem.

I'm glad the problem was solved, and follow the other advices instead, which are wiser
My apologies.

Cheers
Dark Sylinc

This topic is closed to new replies.

Advertisement