File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 18
18
use OCP \Server ;
19
19
use OCP \Share ;
20
20
use OCP \User \Events \UserChangedEvent ;
21
+ use OCP \Util ;
21
22
use Psr \Log \LoggerInterface ;
22
23
use Symfony \Component \Routing \Exception \MethodNotAllowedException ;
23
24
use function OCP \Log \logger ;
@@ -828,6 +829,21 @@ public static function init(): void {
828
829
register_shutdown_function (function () use ($ eventLogger ) {
829
830
$ eventLogger ->end ('request ' );
830
831
});
832
+
833
+ register_shutdown_function (function () {
834
+ $ memoryPeak = memory_get_peak_usage ();
835
+ $ logLevel = match (true ) {
836
+ $ memoryPeak > 500_000_000 => ILogger::FATAL ,
837
+ $ memoryPeak > 400_000_000 => ILogger::ERROR ,
838
+ $ memoryPeak > 300_000_000 => ILogger::WARN ,
839
+ default => null ,
840
+ };
841
+ if ($ logLevel !== null ) {
842
+ $ message = 'Request used more than 300 MB of RAM: ' . Util::humanFileSize ($ memoryPeak );
843
+ $ logger = Server::get (LoggerInterface::class);
844
+ $ logger ->log ($ logLevel , $ message , ['app ' => 'core ' ]);
845
+ }
846
+ });
831
847
}
832
848
833
849
/**
You can’t perform that action at this time.
0 commit comments