Sign in to follow this  
lack o comments

Best time to release EVERYTHING?

Recommended Posts

I have been meaning to ask this since that first fateful day I put down Turbo C++ picked up VC6 and started converting all my DOS stuff to DirectX ;) Can I release everything in a vector supplied by "atexit()"? I think someone once told me that it SHOULD be done before the return from WinMain. But that was never really definite.

Share this post


Link to post
Share on other sites
If you must "release" the elements of a vector, you must do it before the vector itself is "released" or goes out of scope.

You can release COM objects in an atexit function. I don't think it will hurt anything, but that is probably not the best way to do it.

Your question is a little unclear, I hope one of these answered it.

Share this post


Link to post
Share on other sites
I had to double check the date this message was posted. Turbo C++ and DOS :-)

I think you should look for another way to release your data than using atexit.


Share this post


Link to post
Share on other sites
1) Any object which takes a HWND as a parameter to its Create*() call should be released BEFORE the window the HWND refers to has been destroyed (i.e. before DestroyWindow()).

2) When you Create*() any object which takes a HWND, you should do it when the creation of that window has truly completed (i.e. preferably after CreateWindow() succeeds rather from any windows message you may get half-way through creation).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this