Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Server exhausted

Comments in 'Plugin Development' started by xBeastMode, Jan 24, 2016.

  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    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), 00);
                    }
                    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()]);
            }
        }
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I don't see any memory exhausting thingys. Do you know how much RAM your server has?
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Don't use static properties. Why do you even use it?
    Vaivez66 likes this.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Why not? color::clean is a static pocketmine function.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This is a function, not a property.
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    A static property cause lag?
    What if I cancel tasks from a array?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    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.
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I've figured out that the Server exhaust only happens with netherbox, but in my home server it runs fine.
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    NetherBox rip-off?

Share This Page

Advertisement