Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit 37fd037

Browse files
committed
Added GarbageCollectionTask, workaround for weird PHP behaviour when using --disable-ansi
1 parent ed02026 commit 37fd037

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/pocketmine/Server.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
use pocketmine\plugin\PluginLoadOrder;
8787
use pocketmine\plugin\PluginManager;
8888
use pocketmine\scheduler\CallbackTask;
89+
use pocketmine\scheduler\GarbageCollectionTask;
8990
use pocketmine\scheduler\SendUsageTask;
9091
use pocketmine\scheduler\ServerScheduler;
9192
use pocketmine\tile\Chest;
@@ -1688,6 +1689,8 @@ public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $
16881689
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doLevelGC"]), $this->getProperty("chunk-gc.period-in-ticks", 600), $this->getProperty("chunk-gc.period-in-ticks", 600));
16891690
}
16901691

1692+
$this->scheduler->scheduleRepeatingTask(new GarbageCollectionTask(), 900);
1693+
16911694
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
16921695

16931696
$this->start();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\scheduler;
23+
24+
class GarbageCollectionTask extends Task{
25+
26+
public function onRun($currentTicks){
27+
gc_collect_cycles();
28+
memory_get_usage();
29+
memory_get_usage(true);
30+
}
31+
32+
}

0 commit comments

Comments
 (0)