   global variables not deconstructing in release build (VC++)
  I was forced to switch to release build because of some linker problem I couldnt fix and now I get an error about directx reference counts when I close the program.  The only explanation I can think of is that for some reason my global variables arent being deconstructed.  Three of them rely on the deconstructors to release textures and buffers and since I wasnt getting this error before it makes sense.  Is this supposed to happen? and if so how do I fix it?  I cant manually deconstruct them without making them pointers.   
  If you're using destructors to release your textures and buffers, and these are stored withing objects in the global scope, how can you be sure that your objects are being destroyed before your main graphics device?For example, are you sure that you are releasing your textures before your main IDirect3DDevice9 is released?  This could be your problem.I got reference counting errors even on some of the SDK demos.  Maybe these "smart" pointers aren't as intelligent as we think...   ;  do the textures have the be released before the device?  I didnt think they had to so I just release them in the deconstructor.  I didnt get any errors when I ran it in debug mode..   ;  I don't really know.  The documentation doesn't really say but it DOES say that it is a good idea to release things in reverse creation-order.  So if you can't create a texture before creating a Direct3D device, then it is dependent on that device.  That means you should probably destroy it before your render device is destroyed to ensure that there aren't any internal references to devices that do not exist, etc.   ;  eh I did that and it worked but it still seems to me like global variables dont deconstruct in a release build...   ;  Release builds will not prevent destructors from being called.If your objects are genuinely not being destructed, then you have a bug - you're doing something that's preventing it, like forgetting to delete an object, using smart pointers with circular references, etc. It's possible that something insidious is happening also, such as a stack overflow that causes the program to silently crash and disappear. But in any case the cause is not merely that you compiled a release build.Try putting a call to ::MessageBox in one of your objects' destructors - you'll see if it is getting called or not.To prove that destructors in general are working, paste this into one of your code files:class __DestructorTestDebug{public:   ~__DestructorTestDebug()   { ::MessageBox(0, "Destructor was called!", "Debug", 0);   }};static __DestructorTestDebug __dtdebugobj;;  a global variable. Like a variable which has actual dynamic use in your program and is accessible everywhere?IMO thats bad design.the only thing i make global are constants.   ;  its just a quick test program for my particle systems, Im making each system a global variable just cause its quick and easy.  They arent pointers so there is no deleteing them, they should automatically free themselves.  I know for a fact that their textures are not being released and thats causing the errors.  I also know that when I was building it in debug mode I got no errors (I did get reference count errors in debug mode for other bugs, I know they werent disabled or anything).  The obvious conclusion is that the deconstructor is for some reason not automatically called in release mode.  There might be some other explanations but I dont rly see em.. (maybe DXUT does something different with device releasing in release mode than in debug?).  Thanks for the help anyway tho, it was a bad design regardless so I added in a releaseTextures() function to release them before the device is released.   ;  o and also, my console box stopped showing up when I switched to release.  How weird is that? it only shows up now when I close my DX window.  I manually create it, its not some compiler made one.   ;  hmm I set the console box to only show up if DEBUG was defined but I define it still at the beginning of the program... maybe they compiler undefines it?neway, the deconstructor is called, thanks for that MessageBox thing, never knew about it could be useful.  Guess DXUT must be different in release than in debug...   