Sign in to follow this  

App quit without cleaning resources

This topic is 1111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone!

I was wondering... what happens if i do std::exit() without freeing all opengl resources
( Shaders, Fbos, textures etc... )

Would they still be in memory after quiting my app or everything will be automatically cleared up after std:exit call?
Thanks.

Share this post


Link to post
Share on other sites
Let's say it is the same reason why you should calling delete after assigning the new operator in a pointer, but now assume we're using the GPU memory.
std::exit have a well defined behaviour, but why you want to call it instead of calling My App.Exit() which is a much better OOP approach and facilitates the readability of the exiting propagation of your application? It is fine for your console examples but for real production might not be a good one. happy.png
 
Read the documentation of the API you're using. E.g:
 
Name

glDeleteShader — delete a shader object

C Specification
void glDeleteShader( GLuint shader);
 
Parameters
shader

Specifies the shader object to be deleted.

Description

glDeleteShader frees the memory and invalidates the name associated with the shader object specified by shader. This command effectively undoes the effects of a call to glCreateShader. (...)

Edited by Irlan

Share this post


Link to post
Share on other sites

Well, technically it's pretty a fairly safe thing to do, in that the GPU resources will get freed so you won't leak memory (unless the video driver is buggy, so you probably will leak memory -- one major GPU vendor's binary blob video driver on Linux is widely known to leak memory like that, forcing a reboot to recover).

 

The video drivers themselves know about your process, including the binary executable you're running and when it starts and stops (this is necessary for GPU vendors to compete on some benchmarks and to provide workarounds for well-known buggy applications. This has historically caused problems with (a) ethics and (2) fixing the buggy applications).

 

It's not really a good idea to just up and exit() in normal practice, since it can create so many false positives in your analysis tools as to render them, and much of your extensive test suite, useless.  Of course, if you don't care about quality, that's not an issue so most of you can just go ahead and exit() at will.

Share this post


Link to post
Share on other sites
Its good practice.. makes you feel good you have a handle on all the acquiring and releasing of memory of course.

Is it the end of the world if you don't do it? Not usually, practically speaking unless you have really -bad- drivers everything ends up freed when your process terminates no matter how it happens.

It certainly doesn't hurt to do it though.

Share this post


Link to post
Share on other sites

This topic is 1111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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