Skip to content

Commit

Permalink
Re-enter loop to ensure references are dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Nov 19, 2023
1 parent ad46c94 commit 71fe5cf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/Driver/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 71fe5cf

Please sign in to comment.