Fixed AsyncWorker GC not getting re-enabled after memory dump

async workers still use automatic GC for now. We should probably switch to manual GC at some point, but it's not a priority right now.
This commit is contained in:
Dylan K. Taylor 2024-12-15 20:45:51 +00:00
parent 742aa46b88
commit 45482e868d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -33,6 +33,7 @@ use function file_put_contents;
use function fopen;
use function fwrite;
use function gc_disable;
use function gc_enabled;
use function get_class;
use function get_declared_classes;
use function get_defined_functions;
@ -66,6 +67,7 @@ final class MemoryDump{
public static function dumpMemory(mixed $startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger) : void{
$hardLimit = Utils::assumeNotFalse(ini_get('memory_limit'), "memory_limit INI directive should always exist");
ini_set('memory_limit', '-1');
$gcEnabled = gc_enabled();
gc_disable();
if(!file_exists($outputFolder)){
@ -244,6 +246,9 @@ final class MemoryDump{
$logger->info("Finished!");
ini_set('memory_limit', $hardLimit);
if($gcEnabled){
gc_enable();
}
}
/**