[LWJGL] Why should we call Display.destroy()?

My first post here at JGO and hence I hope I ask this in the right section.

I was going over tutorials and documentation on LWJGL and was wondering, why would one need to call Display.destroy(), right before the end?

Since, at the end post the JVM shutdown, would not any resources claimed by that process be returned back?

To ask the question in another way, say I have:



// ...
Display.setDisplayMode(new DisplayMode(800,600));
Display.create();

// ... do some LWJGL stuff

// ... no Display.destroy();
System.exit(0);


And I run the above, what would happen?

Software is often like being polite, you don’t have to say thank you but it’s nice.

Display.destroy() when you shutdown the VM just afterwards seems unlikely to have any effect, but you don’t know what resources it might be holding. In a more generic case the system could be holding temporary files or separate processes that a clean up method would … well clean up.

So be polite, call destroy anyway, it might at some point be something thats worth doing and it’s very polite :wink:

Cheers,

Kev

Just remember how often your game crashes while it’s in development. All these times the process terminated without having called [icode]Display.destroy()[/icode]. The gfx-driver will clean up after you, no matter what, but that doesn’t mean you should give it the finger :slight_smile:

Well… it is actually an entirely optional call, but it has its uses. When you want your game to look like it’s shut down quickly and successfully it’s the first thing you want to zap. You can then get on with doing any other bits of housekeeping… in particular stuff like “logging out” or writing logs in a background thread as the app terminates.

If you aren’t doing any of these things there’s honestly no need to call it as it will be no more or less effective than what the OS is doing in the background when your process terminates.

Cas :slight_smile:

Never thought of it like that. I am eating my humble pie now.

Understood. Not really required to do. But I should generally get into the process of doing [icode]Display.destroy()[/icode] at a logical point, just so that when I have bigger processes/operations, it ‘fits into place’ properly.

Thanks guys!