@@ -226,21 +226,33 @@ private function runCli(string $appMode, ?array $jobClasses): void {
226226 ['app ' => 'cron ' ]
227227 );
228228 }
229-
230- if ($ memoryIncrease > 50 * 1024 * 1024 ) {
231- $ message = 'Memory leak detected after executing job ' . $ jobDetails . '. Memory usage grew by ' . Util::humanFileSize ($ memoryIncrease ) . '. ' ;
229+ if ($ jobMemoryPeak > (300 * 1024 * 1024 )) {
230+ $ message
231+ = 'Cron job used more than 300 MiB of RAM after executing job '
232+ . $ jobDetails
233+ . ': '
234+ . Util::humanFileSize ($ jobMemoryPeak )
235+ . ') ' ;
232236 $ this ->logger ->warning ($ message , ['app ' => 'cron ' ]);
233237 $ this ->verboseOutput ($ message );
234238 }
235- if ($ jobMemoryPeak > 300 * 1024 * 1024 ) {
236- $ message = 'Cron job used more than 300 MiB of RAM after executing job ' . $ jobDetails . ': ' . Util::humanFileSize ($ jobMemoryPeak ) . ') ' ;
239+
240+ // Clean-up
241+ $ this ->setupManager ->tearDown ();
242+ $ this ->tempManager ->clean ();
243+
244+ if ($ memoryIncrease > (50 * 1024 * 1024 )) {
245+ $ message
246+ = 'Memory leak detected after executing job '
247+ . $ jobDetails
248+ . '. Memory usage grew by '
249+ . Util::humanFileSize ($ memoryIncrease )
250+ . '. ' ;
237251 $ this ->logger ->warning ($ message , ['app ' => 'cron ' ]);
238252 $ this ->verboseOutput ($ message );
239253 }
240254
241- // clean up after unclean jobs
242- $ this ->setupManager ->tearDown ();
243- $ this ->tempManager ->clean ();
255+ // Check forgotten transaction
244256 if ($ this ->connection ->inTransaction ()) {
245257 $ this ->connection ->rollBack ();
246258 $ message = 'Cron job left a transaction opened after executing job ' . $ jobDetails . '. The transaction was rolled back. ' ;
0 commit comments