From 71fe5cf6cdb797fc82120a2ef25dee198f926658 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 19 Nov 2023 08:19:15 -0600 Subject: [PATCH] Re-enter loop to ensure references are dropped --- test/Driver/DriverTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/Driver/DriverTest.php b/test/Driver/DriverTest.php index eaafcc5..b90c168 100644 --- a/test/Driver/DriverTest.php +++ b/test/Driver/DriverTest.php @@ -602,14 +602,21 @@ public function testNoMemoryLeak(string $type, array $args): void $loop->run(); } }; + $closureMem = \memory_get_usage() - $initialMem; $cb($runs); /* just to set up eventual structures inside loop without counting towards memory comparison */ + \gc_collect_cycles(); + $initialMem = \memory_get_usage() - $closureMem; $cb($runs); unset($cb); \gc_collect_cycles(); + + $loop->delay(0, fn() => null); + $loop->run(); + $endMem = \memory_get_usage(); /* this is allowing some memory usage due to runtime caches etc., but nothing actually leaking */