Advertisement

Releasing resources on exit

Started by April 09, 2019 06:47 PM
7 comments, last by JohnnyCode 5 years, 9 months ago

is it a good idea to release resources in DX11 when you exit an application these days... if you don't what problems can happen?

Currently in my app I don't release anything on exiting... and so far no problems.. but I suppose this is not good.. In DX9 it could sometimes cause problems I seem to recall.

The reason I don't release stuff right now is just because it's tedious...no real better reason.

I think it depends what you intend to do with the final bits. If for instance you are creating a middleware SDK that could be rendering in one or more C# SwapChainPanels provided by the WRT, then resource consumption would grow without ever decreasing. If your just using your code in a legacy Win32 desktop app, everything will be cleaned up for you by the runtime and OS when your app terminates (cleanly or not).

Advertisement

OK it's just for a win32 application so I guess I won't bother releasing unless it causes problems... thanks.

Note also that this will be considered as a non-cleaned code.

And if, for some reasons (ie a bug on DX side or Windows side), these resources are not freed, then you might run into issues.

Why don't using ComPtr instead of raw pointer?

If releasing resources is tedious, you're doing it wrong.  Use RAII.  Use smart pointers such as ComPtr.  Do not ever use a raw pointer to "own" a resource, unless you are writing your own smart pointer class.

In a well-written program, releasing resources is something that happens effortlessly.

Advertisement

Well I should explain...basically  I don't have to worry about "ownership".. the resources are all global pointers...and I don't use classes and such and there is no "scoping" of pointers.. this is a pretty simple game program

 

You should be full safe if application is terminated if this is what you are asking for

This topic is closed to new replies.

Advertisement