Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LWJGL] Why should we call Display.destroy()?  (Read 2567 times)
0 Members and 1 Guest are viewing this topic.
Offline Vyoma

Junior Newbie





« Posted 2014-09-09 06:19:51 »

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:

1  
2  
3  
4  
5  
6  
7  
8  
// ...
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?
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2014-09-09 06:26:01 »

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

Offline Riven
Administrator

« JGO Overlord »


Medals: 1356
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2014-09-09 06:30:23 »

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

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 1058
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2014-09-09 08:37:38 »

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 Smiley

Offline Vyoma

Junior Newbie





« Reply #4 - Posted 2014-09-09 08:46:48 »

Software is often like being polite, you don't have to say thank you but it's nice.
...
...
So be polite, call destroy anyway, it might at some point be something thats worth doing and it's very polite Wink
...

... The gfx-driver will clean up after you, no matter what, but that doesn't mean you should give it the finger Smiley

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

...
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 Smiley

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

Thanks guys!
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1599 views)
2018-06-10 19:43:48

EgonOlsen (1700 views)
2018-06-10 19:43:44

EgonOlsen (1154 views)
2018-06-10 19:43:20

DesertCoockie (1582 views)
2018-05-13 18:23:11

nelsongames (1182 views)
2018-04-24 18:15:36

nelsongames (1705 views)
2018-04-24 18:14:32

ivj94 (2473 views)
2018-03-24 14:47:39

ivj94 (1690 views)
2018-03-24 14:46:31

ivj94 (2771 views)
2018-03-24 14:43:53

Solater (910 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!