Added MemoryManager, new memory properties, improved performance, updated RakLib, fixed misc. bugs

This commit is contained in:
Shoghi Cervantes
2015-04-18 20:13:52 +02:00
parent ddc152ae0a
commit b2c25eaf36
32 changed files with 652 additions and 164 deletions

View File

@ -33,6 +33,8 @@ abstract class Timings{
/** @var TimingsHandler */
public static $serverTickTimer;
/** @var TimingsHandler */
public static $garbageCollectorTimer;
/** @var TimingsHandler */
public static $playerListTimer;
/** @var TimingsHandler */
public static $connectionTimer;
@ -96,6 +98,7 @@ abstract class Timings{
}
self::$serverTickTimer = new TimingsHandler("** Full Server Tick");
self::$garbageCollectorTimer = new TimingsHandler("Garbage Collector");
self::$playerListTimer = new TimingsHandler("Player List");
self::$connectionTimer = new TimingsHandler("Connection Handler");
self::$tickablesTimer = new TimingsHandler("Tickables");

View File

@ -0,0 +1,79 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\server;
use pocketmine\utils\Utils;
/**
* Called when the server is in a low-memory state as defined by the properties
* Plugins should free caches or other non-essential data.
*/
class LowMemoryEvent extends ServerEvent{
public static $handlerList = null;
private $memory;
private $memoryLimit;
private $triggerCount;
public function __construct($memory, $memoryLimit, $triggerCount = 0){
$this->memory = $memory;
$this->memoryLimit = $memoryLimit;
$this->triggerCount = (int) $triggerCount;
}
/**
* Returns the memory usage at the time of the event call (in bytes)
*
* @return int
*/
public function getMemory(){
return $this->memory;
}
/**
* Returns the memory limit defined (in bytes)
*
* @return int
*/
public function getMemoryLimit(){
return $this->memory;
}
/**
* Returns the times this event has been called in the current low-memory state
*
* @return int
*/
public function getTriggerCount(){
return $this->triggerCount;
}
/**
* Amount of memory already freed
*
* @return int
*/
public function getMemoryFreed(){
return $this->getMemory() - Utils::getMemoryUsage();
}
}