/** * @public * destroy all objects */ public static function destroyAllObjects() { $objectManager = ObjectManager::getInstance(); self::$objects = $objectManager->getAllObjectInstances(); foreach (self::$objects as $key => $ObjectInstance) { if (is_object($ObjectInstance)) { self::destroyObject($ObjectInstance); } } self::BufferEmpty(); }
/** * Allocates a new variable into memory. * @param &mixed $var Variable reference to count. * @return int Variable address in the memory collection * @throws OutOfMemoryException */ public static function alloc(&$var) { $memory = self::getInstance(); GarbageCollector::collect(); // GC checks cycles to know if it has to actually collect or not if (self::$lastAddress < PHP_INT_MAX) { $memory[++self::$lastAddress] =& $var; return self::$lastAddress; } elseif (count($memory) == PHP_INT_MAX) { throw new OutOfMemoryException(); } else { do { $address = rand(1, PHP_INT_MAX); } while (isset($memory[$address])); $memory[$address] =& $var; return $address; } }