diff --git a/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php b/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php index 5754508f600..0537766e825 100644 --- a/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php +++ b/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php @@ -29,6 +29,13 @@ public function execute() parent::execute(); for ($i = 0; $i < self::$jobsPerRun; $i++) { + // Reset the memory usage for each background job, allowing to measure each individual + // background job's memory usage without a memory-heavy job skewing the numbers for + // the following jobs. + if (\PHP_VERSION_ID >= 80200) { + \memory_reset_peak_usage(); + } + if (BackgroundQueueHandler::getInstance()->performNextJob() === false) { // there were no more jobs break; diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index 5e43bbfe783..448d96b184a 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -60,6 +60,13 @@ public function executeCronjobs() SessionHandler::getInstance()->changeUser(new User(null), true); foreach ($cronjobEditors as $cronjobEditor) { + // Reset the memory usage for each cronjob, allowing to measure each individual + // cronjob's memory usage without a memory-heavy cronjob skewing the numbers for + // the following cronjobs. + if (\PHP_VERSION_ID >= 80200) { + \memory_reset_peak_usage(); + } + // mark cronjob as being executed $cronjobEditor->update([ 'state' => Cronjob::EXECUTING,