mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 10:49:10 +00:00
Added main-hard-limit memory property similar to old memory-limit, use less memory on startup (RakLib)
This commit is contained in:
parent
1ebf2476df
commit
0c09361c46
@ -68,8 +68,41 @@ class MemoryManager{
|
||||
}
|
||||
|
||||
private function init(){
|
||||
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 320)) * 1024 * 1024;
|
||||
$this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 512)) * 1024 * 1024;
|
||||
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;
|
||||
|
||||
$defaultMemory = 1024;
|
||||
|
||||
if(preg_match("/([0-9]+)([KMGkmg])/", $this->server->getConfigString("memory-limit", ""), $matches) > 0){
|
||||
$m = (int) $matches[1];
|
||||
if($m <= 0){
|
||||
$defaultMemory = 0;
|
||||
}else{
|
||||
switch(strtoupper($matches[2])){
|
||||
case "K":
|
||||
$defaultMemory = $m / 1024;
|
||||
break;
|
||||
case "M":
|
||||
$defaultMemory = $m;
|
||||
break;
|
||||
case "G":
|
||||
$defaultMemory = $m * 1024;
|
||||
break;
|
||||
default:
|
||||
$defaultMemory = $m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
|
||||
|
||||
if($hardLimit <= 0){
|
||||
ini_set("memory_limit", -1);
|
||||
}else{
|
||||
ini_set("memory_limit", $hardLimit . "M");
|
||||
}
|
||||
|
||||
$this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 0)) * 1024 * 1024;
|
||||
$this->checkRate = (int) $this->server->getProperty("memory.check-rate", 20);
|
||||
$this->continuousTrigger = (bool) $this->server->getProperty("memory.continuous-trigger", true);
|
||||
$this->continuousTriggerRate = (int) $this->server->getProperty("memory.continuous-trigger-rate", 30);
|
||||
|
@ -1646,12 +1646,6 @@ class Server{
|
||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
|
||||
|
||||
if($this->getConfigString("memory-limit", false) !== false){
|
||||
$this->logger->notice("The memory-limit setting has been deprecated.");
|
||||
$this->logger->notice("There are new memory settings on pocketmine.yml to tune memory and events.");
|
||||
$this->logger->notice("You can also reduce the amount of threads and chunks loaded control the memory usage.");
|
||||
}
|
||||
|
||||
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
|
||||
$this->setConfigInt("difficulty", 3);
|
||||
}
|
||||
|
@ -27,11 +27,15 @@ settings:
|
||||
memory:
|
||||
#Global soft memory limit in megabytes. Set to 0 to disable
|
||||
#This will trigger low-memory-triggers and fire an event to free memory when the usage goes over this
|
||||
global-limit: 512
|
||||
global-limit: 0
|
||||
|
||||
#Main thread soft memory limit in megabytes. Set to 0 to disable
|
||||
#This will trigger low-memory-triggers and fire an event to free memory when the usage goes over this
|
||||
main-limit: 320
|
||||
main-limit: 0
|
||||
|
||||
#Main thread hard memory limit in megabytes. Set to 0 to disable
|
||||
#This will stop the server when the limit is surpassed
|
||||
main-hard-limit: 1024
|
||||
|
||||
#Period in ticks to check memory (default 1 second)
|
||||
check-rate: 20
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b90c277f1a24fcda49e14510d83a0d956b0ebad7
|
||||
Subproject commit ab3ff4420f6dea3371bfc410bbb783159cd0560b
|
Loading…
x
Reference in New Issue
Block a user