Răsfoiți Sursa

Changed Game::exit() to only perform a full shutdown when either FORCE_CLEAN_SHUTDOWN or GAMEPLAY_MEM_LEAK_DETECTION are defined. By default now (when these are not defined), it simply calls cstdlib ::exit(0), which causes immediate termination of the application. This was done to avoid extremely long shutdown times when trying to do cleanly delete every last pointer in the system, especially for large games. Any modern OS handles reclamation of memory, so there should be no adverse side effects.

Steve Grenier 13 ani în urmă
părinte
comite
147e25c85b
1 a modificat fișierele cu 18 adăugiri și 1 ștergeri
  1. 18 1
      gameplay/src/Game.cpp

+ 18 - 1
gameplay/src/Game.cpp

@@ -258,13 +258,30 @@ void Game::resume()
 
 
 void Game::exit()
 void Game::exit()
 {
 {
-	// Schedule a call to shutdown rather than calling it right away.
+    // Only perform a full/clean shutdown if FORCE_CLEAN_SHUTDOWN or
+    // GAMEPLAY_MEM_LEAK_DETECTION is defined. Every modern OS is able to
+    // handle reclaiming process memory hundreds of times faster than it
+    // would take us to go through every pointer in the engine and release
+    // them nicely. For large games, shutdown can end up taking long time,
+    // so we'll just call ::exit(0) to force an instant shutdown.
+
+#if defined FORCE_CLEAN_SHUTDOWN || defined GAMEPLAY_MEM_LEAK_DETECTION
+
+    // Schedule a call to shutdown rather than calling it right away.
 	// This handles the case of shutting down the script system from
 	// This handles the case of shutting down the script system from
 	// within a script function (which can cause errors).
 	// within a script function (which can cause errors).
 	static ShutdownListener listener;
 	static ShutdownListener listener;
 	schedule(0, &listener);
 	schedule(0, &listener);
+
+#else
+
+    // End the process immediately without a full shutdown
+    ::exit(0);
+
+#endif
 }
 }
 
 
+
 void Game::frame()
 void Game::frame()
 {
 {
     if (!_initialized)
     if (!_initialized)