Free up memory from as many singletons and instantiated objects as possible before terminating
Free up memory from as many singletons and instantiated objects as possible before terminating

--- a/include/Config.class.php
+++ b/include/Config.class.php
@@ -60,6 +60,19 @@
 			self::$instance = new GitPHP_Config();
 		}
 		return self::$instance;
+	}
+
+	/**
+	 * DestroyInstance
+	 *
+	 * Releases the singleton instance
+	 *
+	 * @access public
+	 * @static
+	 */
+	public static function DestroyInstance()
+	{
+		self::$instance = null;
 	}
 
 	/**

--- a/include/Log.class.php
+++ b/include/Log.class.php
@@ -90,6 +90,19 @@
 	}
 
 	/**
+	 * DestroyInstance
+	 *
+	 * Releases the singleton instance
+	 *
+	 * @access public
+	 * @static
+	 */
+	public static function DestroyInstance()
+	{
+		self::$instance = null;
+	}
+
+	/**
 	 * __construct
 	 *
 	 * Constructor

--- a/include/Resource.class.php
+++ b/include/Resource.class.php
@@ -62,6 +62,19 @@
 	public static function GetInstance()
 	{
 		return self::$instance;
+	}
+
+	/**
+	 * DestroyInstance
+	 *
+	 * Releases the singleton instance
+	 *
+	 * @access public
+	 * @static
+	 */
+	public static function DestroyInstance()
+	{
+		self::$instance = null;
 	}
 
 	/**

--- a/include/cache/MemoryCache.class.php
+++ b/include/cache/MemoryCache.class.php
@@ -82,6 +82,19 @@
 	}
 
 	/**
+	 * DestroyInstance
+	 *
+	 * Releases the singleton instance
+	 *
+	 * @access public
+	 * @static
+	 */
+	public static function DestroyInstance()
+	{
+		self::$instance = null;
+	}
+
+	/**
 	 * __construct
 	 *
 	 * Class constructor

--- a/include/git/ProjectList.class.php
+++ b/include/git/ProjectList.class.php
@@ -51,6 +51,19 @@
 	}
 
 	/**
+	 * DestroyInstance
+	 *
+	 * Releases the singleton instance
+	 *
+	 * @access public
+	 * @static
+	 */
+	public static function DestroyInstance()
+	{
+		self::$instance = null;
+	}
+
+	/**
 	 * Instantiate
 	 *
 	 * Instantiates the singleton instance

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -155,6 +155,7 @@
 		$controller->RenderHeaders();
 		$controller->Render();
 	}
+	unset($controller);
 
 } catch (Exception $e) {
 
@@ -182,17 +183,27 @@
 	$controller->RenderHeaders();
 	$controller->Render();
 
+	unset($controller);
+
 }
 
 GitPHP_Log::GetInstance()->Log('MemoryCache count: ' . GitPHP_MemoryCache::GetInstance()->GetCount());
-GitPHP_MemoryCache::GetInstance()->Clear();
+
+GitPHP_MemoryCache::DestroyInstance();
+GitPHP_ProjectList::DestroyInstance();
+GitPHP_Resource::DestroyInstance();
+GitPHP_Config::DestroyInstance();
 
 if (GitPHP_Log::GetInstance()->GetEnabled()) {
 	$entries = GitPHP_Log::GetInstance()->GetEntries();
 	foreach ($entries as $logline) {
 		echo "<br />\n" . $logline;
 	}
-}
+	unset($logline);
+	unset($entries);
+}
+
+GitPHP_Log::DestroyInstance();
 
 ?>
 

comments