Hi there,

Having just recently fixed an issue with memory leaks and DirectX objects still being live after shutdown I was wondering if it's a bad idea to create a class using the 'new' keyword if it contains smart pointers?

I was using 'new' to make a class that does some basic rendering stuff that worked quite nicely until it came time to close the window and thus the program. The debugger was showing all kinds of issues as mentioned above. I made sure I had a 'delete this' line in the class destructor too.

Some of the problems experienced were multiple class destructor calls, seemingly infinite amounts of them. I should note that the class gets created inside a DLL file and then a pointer to it is returned to the program that creates the DLL. If that makes any difference.

However when I just made a global variable of the class type (something I was trying to avoid) there were no problems at all. The only issues I seemed to have was calling the Release methods on the COMPtrs in the destructor showed a memory access issue. Most likely because these smart pointers had already called their release methods when they went out of scope.

So I'm thinking is this a possibility? Maybe not a good idea to use the rather old keyword 'new' in combination with smart pointers?

Thanks