mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Moved chunk garbage collector to memory manager
This commit is contained in:
parent
05385acb36
commit
bf4a8398c4
@ -48,6 +48,7 @@ class MemoryManager{
|
|||||||
private $garbageCollectionAsync;
|
private $garbageCollectionAsync;
|
||||||
|
|
||||||
private $chunkLimit;
|
private $chunkLimit;
|
||||||
|
private $chunkCollect;
|
||||||
private $chunkTrigger;
|
private $chunkTrigger;
|
||||||
|
|
||||||
private $chunkCache;
|
private $chunkCache;
|
||||||
@ -71,6 +72,7 @@ class MemoryManager{
|
|||||||
$this->garbageCollectionAsync = (bool) $this->server->getProperty("memory.garbage-collection.collect-async-worker", true);
|
$this->garbageCollectionAsync = (bool) $this->server->getProperty("memory.garbage-collection.collect-async-worker", true);
|
||||||
|
|
||||||
$this->chunkLimit = (int) $this->server->getProperty("memory.max-chunks.trigger-limit", 12000);
|
$this->chunkLimit = (int) $this->server->getProperty("memory.max-chunks.trigger-limit", 12000);
|
||||||
|
$this->chunkCollect = (bool) $this->server->getProperty("memory.max-chunks.trigger-chunk-collect", true);
|
||||||
$this->chunkTrigger = (bool) $this->server->getProperty("memory.max-chunks.low-memory-trigger", true);
|
$this->chunkTrigger = (bool) $this->server->getProperty("memory.max-chunks.low-memory-trigger", true);
|
||||||
|
|
||||||
$this->chunkCache = (bool) $this->server->getProperty("memory.world-caches.disable-chunk-cache", true);
|
$this->chunkCache = (bool) $this->server->getProperty("memory.world-caches.disable-chunk-cache", true);
|
||||||
@ -100,6 +102,12 @@ class MemoryManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->chunkTrigger and $this->chunkCollect){
|
||||||
|
foreach($this->server->getLevels() as $level){
|
||||||
|
$level->doChunkGarbageCollection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
|
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
|
||||||
$this->server->getPluginManager()->callEvent($ev);
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
|
|
||||||
|
@ -1707,10 +1707,6 @@ class Server{
|
|||||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doAutoSave"]), $this->getProperty("ticks-per.autosave", 6000), $this->getProperty("ticks-per.autosave", 6000));
|
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doAutoSave"]), $this->getProperty("ticks-per.autosave", 6000), $this->getProperty("ticks-per.autosave", 6000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->getProperty("chunk-gc.period-in-ticks", 600) > 0){
|
|
||||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doLevelGC"]), $this->getProperty("chunk-gc.period-in-ticks", 600), $this->getProperty("chunk-gc.period-in-ticks", 600));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
||||||
|
|
||||||
$this->start();
|
$this->start();
|
||||||
@ -2223,12 +2219,6 @@ class Server{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doLevelGC(){
|
|
||||||
foreach($this->getLevels() as $level){
|
|
||||||
$level->doChunkGarbageCollection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sendUsage(){
|
public function sendUsage(){
|
||||||
if($this->lastSendUsage instanceof SendUsageTask){
|
if($this->lastSendUsage instanceof SendUsageTask){
|
||||||
if(!$this->lastSendUsage->isGarbage()){ //do not call multiple times
|
if(!$this->lastSendUsage->isGarbage()){ //do not call multiple times
|
||||||
|
@ -56,6 +56,10 @@ memory:
|
|||||||
max-chunks:
|
max-chunks:
|
||||||
#Limit of chunks to load per player, overrides chunk-sending.max-chunks
|
#Limit of chunks to load per player, overrides chunk-sending.max-chunks
|
||||||
trigger-limit: 96
|
trigger-limit: 96
|
||||||
|
|
||||||
|
#Do chunk garbage collection on trigger
|
||||||
|
trigger-chunk-collect: true
|
||||||
|
|
||||||
#Trigger on low memory
|
#Trigger on low memory
|
||||||
low-memory-trigger: true
|
low-memory-trigger: true
|
||||||
|
|
||||||
@ -117,9 +121,6 @@ chunk-generation:
|
|||||||
#Max. amount of chunks in the waiting queue to be populated
|
#Max. amount of chunks in the waiting queue to be populated
|
||||||
population-queue-size: 2
|
population-queue-size: 2
|
||||||
|
|
||||||
chunk-gc:
|
|
||||||
period-in-ticks: 600
|
|
||||||
|
|
||||||
ticks-per:
|
ticks-per:
|
||||||
animal-spawns: 400
|
animal-spawns: 400
|
||||||
monster-spawns: 1
|
monster-spawns: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user