Skip to content

Commit 159743d

Browse files
committed
Fix: Worker memory leak
1 parent 6804b45 commit 159743d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Inspector/Client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
use function Co\async;
2727
use function Co\channel;
2828
use function Co\onSignal;
29+
use function Co\repeat;
2930
use function Co\wait;
3031
use function config_path;
3132
use function file_exists;
3233
use function shell_exec;
3334
use function sprintf;
3435
use function storage_path;
36+
use function gc_collect_cycles;
3537

3638
use const PHP_BINARY;
3739
use const SIGINT;
@@ -163,6 +165,10 @@ private function monitor(): void
163165
}
164166

165167
cli_set_process_title('laravel-ware');
168+
repeat(static function () {
169+
gc_collect_cycles();
170+
\Co\sleep(1);
171+
}, 1);
166172
wait();
167173
}
168174

src/Virtual/server.bin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use function Co\async;
3232
use function Co\channel;
3333
use function Co\onSignal;
34+
use function Co\repeat;
3435
use function Co\wait;
3536

3637
\cli_set_process_title('laravel-virtual');
@@ -126,7 +127,7 @@ function app(string $abstract = null, array $parameters = []): mixed
126127
$projectChannel = channel(RIP_PROJECT_PATH);
127128
$includedFiles = \get_included_files();
128129
$hotReload = static function (string $file) use ($manager, $includedFiles, $projectChannel) {
129-
if (!is_file($file)) {
130+
if (!\is_file($file)) {
130131
return;
131132
}
132133

@@ -177,4 +178,8 @@ function app(string $abstract = null, array $parameters = []): mixed
177178
/*** start */
178179
Output::info("[laravel-ripple]", 'started');
179180
$manager->run();
181+
repeat(static function () {
182+
\gc_collect_cycles();
183+
\Co\sleep(1);
184+
}, 1);
180185
wait();

0 commit comments

Comments
 (0)