diff --git a/lib/EvReactor.php b/lib/EvReactor.php index da70b29..8a77174 100644 --- a/lib/EvReactor.php +++ b/lib/EvReactor.php @@ -111,6 +111,8 @@ class EvReactor implements Reactor { $this->loop->run($flags); } + \gc_collect_cycles(); + $this->state = self::STOPPED; if ($this->stopException) { $e = $this->stopException; diff --git a/lib/LibeventReactor.php b/lib/LibeventReactor.php index 653a5c3..72f146c 100644 --- a/lib/LibeventReactor.php +++ b/lib/LibeventReactor.php @@ -92,6 +92,8 @@ class LibeventReactor implements Reactor { \event_base_loop($this->keepAliveBase, $flags); } + \gc_collect_cycles(); + $this->state = self::STOPPED; if ($this->stopException) { $e = $this->stopException; diff --git a/lib/NativeReactor.php b/lib/NativeReactor.php index a399f60..f0391e4 100644 --- a/lib/NativeReactor.php +++ b/lib/NativeReactor.php @@ -73,6 +73,8 @@ class NativeReactor implements Reactor { } } + \gc_collect_cycles(); + $this->timersEnabled = false; $this->state = self::STOPPED; } diff --git a/lib/UvReactor.php b/lib/UvReactor.php index 472e189..343bb60 100644 --- a/lib/UvReactor.php +++ b/lib/UvReactor.php @@ -93,6 +93,8 @@ class UvReactor implements Reactor { \uv_run($this->loop, \UV::RUN_DEFAULT | (empty($this->immediates) ? \UV::RUN_ONCE : \UV::RUN_NOWAIT)); } + \gc_collect_cycles(); + $this->state = self::STOPPED; if ($this->stopException) { $e = $this->stopException; @@ -134,7 +136,7 @@ class UvReactor implements Reactor { "Cannot tick() recursively; event reactor already active" ); } - + $this->state = self::TICKING; $noWait = (bool) $noWait; @@ -144,7 +146,7 @@ class UvReactor implements Reactor { break; } } - + // Check the conditional again because a manual stop() could've changed the state if ($this->state) { $flags = $noWait || !empty($this->immediates) ? (\UV::RUN_NOWAIT | \UV::RUN_ONCE) : \UV::RUN_ONCE;