diff --git a/lib/base.php b/lib/base.php index 5bab5d9f3f699..6240a7043aca8 100644 --- a/lib/base.php +++ b/lib/base.php @@ -18,6 +18,7 @@ use OCP\Server; use OCP\Share; use OCP\User\Events\UserChangedEvent; +use OCP\Util; use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Exception\MethodNotAllowedException; use function OCP\Log\logger; @@ -820,6 +821,15 @@ public static function init(): void { register_shutdown_function(function () use ($eventLogger) { $eventLogger->end('request'); }); + + register_shutdown_function(function () { + $memoryPeak = memory_get_peak_usage(); + if ($memoryPeak > 300_000_000) { + $message = 'Request used more than 300 MB of ram: ' . Util::humanFileSize($memoryPeak); + $logger = \OCP\Server::get(LoggerInterface::class); + $logger->warning($message, ['app' => 'core']); + } + }); } /**