views:

83

answers:

2

Just curious if my destructors are being called.
(Specifically for Visual Studio, when you hit the red stop button)

+2  A: 

~~~~~~~~~~~
Nope.
~~~~~~~~~~~

zildjohn01
+4  A: 

No the process is terminated in VS2005, VS2008 and VS2010 when you press stop debugging.

You can easily check this by making a destructor that writes something to a file (and flushes output).

I'm not sure what standard you mean, but there is no standard that would define this behavior.

Brian R. Bondy
So then resources are never released? The reason I ask is that I've been asked to fix some DirectX code which crashes the *second* time it is run, if the first time was stopped mid-debug session.
BlueRaja - Danny Pflughoeft
@blueRaja: Windows will free up any allocated memory handles on the heap and reclaim any unclosed file handles upon process termination. It may not do it immediately, but it usually does it within a few seconds. Destructors will not be called though, so if you for example write to a file in a destructor, then this output will not happen. Also there are probably some resources which windows can't reclaim.
Brian R. Bondy