RakLibServer: disable GC

GC is not required for RakLib as it doesn't generate any unmanaged cycles.
Cycles in general do exist (e.g. Server <-> ServerSession), but these are
explicitly cleaned up, so GC wouldn't have any useful work to do.
This commit is contained in:
Dylan K. Taylor 2024-12-19 20:33:40 +00:00
parent aee358d329
commit fea17fa4a9
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -38,7 +38,7 @@ use raklib\server\ServerSocket;
use raklib\server\SimpleProtocolAcceptor;
use raklib\utils\ExceptionTraceCleaner;
use raklib\utils\InternetAddress;
use function gc_enable;
use function gc_disable;
use function ini_set;
class RakLibServer extends Thread{
@ -82,10 +82,9 @@ class RakLibServer extends Thread{
}
protected function onRun() : void{
//TODO: switch to manually triggered GC
//the best time to do it is between ticks when the server would otherwise be sleeping, but RakLib's current
//design doesn't allow this as of 1.1.1
gc_enable();
//RakLib has cycles (e.g. ServerSession <-> Server) but these cycles are explicitly cleaned up anyway, and are
//very few, so it's pointless to waste CPU time on GC
gc_disable();
ini_set("display_errors", '1');
ini_set("display_startup_errors", '1');