Skip to content

Commit 4d4e748

Browse files
committed
Reset the peak memory usage for each job in BackgroundQueuePerformAction
This is specifically implemented in the controller instead of the BackgroundQueueHandler, since the controller only has a single purpose: Executing multiple different and a-priori unknown jobs. Measuring the peak memory usage of the entire request is not useful there. For other, user-facing, controllers the peak memory usage of an entire request is more meaningful, since they also perform other tasks besides executing background jobs. Thus we do not perform the reset in a generic location.
1 parent 0024fb2 commit 4d4e748

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ public function execute()
2929
parent::execute();
3030

3131
for ($i = 0; $i < self::$jobsPerRun; $i++) {
32+
// Reset the memory usage for each background job, allowing to measure each individual
33+
// background job's memory usage without a memory-heavy job skewing the numbers for
34+
// the following jobs.
35+
if (\PHP_VERSION_ID >= 80200) {
36+
\memory_reset_peak_usage();
37+
}
38+
3239
if (BackgroundQueueHandler::getInstance()->performNextJob() === false) {
3340
// there were no more jobs
3441
break;

0 commit comments

Comments
 (0)