Do I have to Release everything before exiting?

Started by
8 comments, last by L. Spiro 12 years, 7 months ago
I'm getting a crash when I release my IDXGISwapChain in fullscreen (using D3D10), which I solved like so:

void shutdown()
{
safeRelease(g_pSimpleEffect);
safeRelease(g_pVertexBuffer);
safeRelease(g_pVertexLayout);
safeRelease(g_pRS);
safeRelease(g_pDepthStencil);
safeRelease(g_pRenderTargetView);
g_pSwapChain->SetFullscreenState(false, NULL); // <-- fix?
safeRelease(g_pSwapChain);
safeRelease(g_pD3DDevice);
}


(I quit when I get WM_DESTROY)


But now I'm wondering, do I even have to release all my Direct3D pointers? Is it safe to just quit without doing anything? Or what is the recommended approach?
Advertisement
Setting the swapchain to not fullscreen before releasing it is the correct approach, as is explained here somewhere.
I'm not really sure, but I think it is not necessary to release the pointers before you quit the application. But it always seemed cleaner to me.
Awesome, found it; thanks! :)
It's good practice to release everything. If nothing else, it means that if you ever find yourself needing to destroy and recreate everything in code, you can use the same code path for this as you use for shutting down.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Not strictly on-topic but people who say, “The game is shutting down. I don’t need to release my resources/memory,” really irk me.
“The operating system will clean it up.” Hello? That isn’t the point.

Shut-down time is a good time to check for memory leaks, but it doesn’t work if you just let everything go. Not releasing things at shut-down is just being lazy and sloppy. It means you don’t care about your project and have no pride in what you are doing.

Now back to your regularly scheduled topic.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

:)
Actually YE, I'm thinking the driver and libraries know how to release these resources better than I do. I can completely bug the driver out, my screen has broken pixels appearing everywhere, and it's forcing me to restart my computer to fix it. I can definitely just come back later at it, for now I'd rather have no bugs.
My rant wasn’t directed at anyone specifically.
Well maybe an ex-coworker of mine from years ago who was rightfully fired after failing so many projects in a row while somehow thinking he was a hot programmer.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

LOL Well anyway, I think it was bugging out my driver because I was releasing objects still being bound, like the vertex buffer.

Not strictly on-topic but people who say, “The game is shutting down. I don’t need to release my resources/memory,” really irk me.
“The operating system will clean it up.” Hello? That isn’t the point.

Shut-down time is a good time to check for memory leaks, but it doesn’t work if you just let everything go. Not releasing things at shut-down is just being lazy and sloppy. It means you don’t care about your project and have no pride in what you are doing.

Now back to your regularly scheduled topic.


L. Spiro

Hehe, that reminds me of this quote by Carmack.

This topic is closed to new replies.

Advertisement