Game takes a while to shut down. [solved]

Started by
3 comments, last by CDProp 16 years, 4 months ago
Hello. I have a very simple beginning of a 2D game going. All it really does at the moment is display one textured quad. One thing I noticed is that it starts up in a split second, but as soon as I hit ESC to quit (done through the wndproc, calls PostQuitMessage()), the game freezes and it takes about 7-8 seconds to shut down. I thought perhaps I was supposed to release my DirectX objects, which neither of the tutorials I read told me to do, but nonetheless I called ::Release() on the IDirect3D9 object and the IDirect3DDevice9 object. I also made sure to call ::Release() on the IDirect3DVertexBuffer9 object on my sprite class's constructor. This did not help. I went back and hovered over those Release() calls just to see what Intellisense tells me, and they just look like pure virtual functions with no implementation. So, I guess they don't do anything. Maybe I'm wrong. I'm also running this in debug mode from within the Visual Studio environment (2005 Express Edition). Maybe that's it? Or maybe that's just how long it takes? If that's the case, that's fine, the only reason I'm asking is that it seems out of the ordinary. Update: The shut down time seems to be proportional to the amount of time that the game was left running. I do recreate my Sprite object on the stack in my render function. Since the vertex buffer is part of the Sprite class, that means that the buffer is being created, locked, and unlocked at least once per frame. My guess is that I'm doing something wrong there. [Edited by - CDProp on November 24, 2007 3:41:19 PM]
Advertisement
Quote:This did not help. I went back and hovered over those Release() calls just to see what Intellisense tells me, and they just look like pure virtual functions with no implementation. So, I guess they don't do anything. Maybe I'm wrong.

I would say so. :)

Quote:
I'm also running this in debug mode from within the Visual Studio environment (2005 Express Edition). Maybe that's it?

This would seem to be the reason, there is a lot of checking which happens in debug to the heap, I would assume you are deleting ( or under the hood) an amount of pointers when exiting the game. although this seems still to be quite some considerable time, on the other hand you should not take any real notice to the length of time of operations in debug mode.
Uh oh, it was the texture, lol.

I ran it outside of visual studio and it didn't take more than a split second to shut down, but when it ran that time, my quad was white because it couldn't load the texture (the working directory was different). So, I pasted the texture into the right directory. That time, the quad was properly textured but it took forever to shut down again. Since the LPDIRECT3DTEXTURE9 was a property of the sprite, and since the sprite object was being recreated on the stack each frame, I was basically calling D3DXCreateTextureFromFileEx every frame and never releasing them.

GAH!
Turn on DirectX debugging in the control panel and this information should be portrayed to you via the IDE.
Cool, thanks!

This topic is closed to new replies.

Advertisement