Skip to content

Commit c3670c2

Browse files
authored
Reset PHP’s peak memory usage when resetting scope for queue worker (#55069)
This is similar to the reset of the total query duration that is already happening. PHP’s peak memory usage is another bit of global state is not useful to keep in a long-running process handling individual self-contained jobs. By resetting the peak memory usage for each executed job it becomes possible to measure a given job’s maximum memory usage accurately, allowing to optimize hardware resources, for example by placing individual jobs with a high-memory usage into their own queue that is executed on a larger worker instance.
1 parent 704555c commit c3670c2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Illuminate/Queue/QueueServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ protected function registerWorker()
216216
$app->forgetScopedInstances();
217217

218218
Facade::clearResolvedInstances();
219+
220+
memory_reset_peak_usage();
219221
};
220222

221223
return new Worker(

0 commit comments

Comments
 (0)