I have a function that overloads my server in .5 seconds and crashes do to low memory. The server is hosted by netherbox, but on my home/test server it does nothing and keeps running perfectly. This is the function, the server says it's due to the Config, and it's saying that I used more memory than the limit. PHP: public function endGame(Player $player, $gm){ $this->games = $gm; if(!isset($this->games[$player->getName()])) return; $game = color::clean($this->games[$player->getName()]->getText()[1]); if(!isset($this->main->tasks[$game])) return; if(isset($this->games[$player->getName()])){ $left = HGGame::getGamePlayerCount($game); if($left <= 1){ $pos = $this->main->getConfig()->getAll()["hg_games"][$game]["lobby_pos"]; $level = $this->main->getServer()->getLevelByName($pos["level"]); foreach(HGGame::$players[$game] as $p) { $p->teleport(new Position($pos["x"], $pos[1], $pos["z"], $level), 0, 0); } unset(HGManagement::$games[$game]); $this->main->getServer()->broadcastMessage(color::AQUA."------------------------------\n".color::GREEN."[HG] The game ".color::GOLD."{$game} ". color::GREEN."is open.\n".color::AQUA."------------------------------"); unset(HGGame::$onWait[$game]); unset(HGGame::$counters[$game]); unset(HGManagement::$players[$game][$player->getName()]); $this->main->getServer()->getScheduler()->cancelTask($this->main->tasks[$game]); unset($this->main->tasks[$game]); } unset(HGGame::$players[$game][spl_object_hash($player)]); unset($this->games[$player->getName()]); } }
It doesn't cause lag. But why use static, while you can use class properties? Avoid saving objects in static class properties or globals. Please provide more information if you want help.
I've figured out that the Server exhaust only happens with netherbox, but in my home server it runs fine.