@@ -915,19 +915,23 @@ public static function init(): void {
915915 $ eventLogger ->end ('request ' );
916916 });
917917
918- register_shutdown_function (function () {
918+ register_shutdown_function (function () use ( $ config ) {
919919 $ memoryPeak = memory_get_peak_usage ();
920+ $ debugModeEnabled = $ config ->getSystemValueBool ('debug ' , false );
921+ $ memoryLimit = null ;
920922
921- // Use the memory helper to get the real memory limit in bytes
922- try {
923- $ memoryInfo = new \OC \MemoryInfo ();
924- $ memoryLimit = $ memoryInfo ->getMemoryLimit ();
925- } catch (Throwable $ e ) {
926- $ memoryLimit = null ;
923+ if (!$ debugModeEnabled ) {
924+ // Use the memory helper to get the real memory limit in bytes if debug mode is disabled
925+ try {
926+ $ memoryInfo = new \OC \MemoryInfo ();
927+ $ memoryLimit = $ memoryInfo ->getMemoryLimit ();
928+ } catch (Throwable $ e ) {
929+ // Ignore any errors and fall back to hardcoded thresholds
930+ }
927931 }
928932
929- // Check if a memory limit is configured and can be retrieved and determine log level
930- if ($ memoryLimit !== null && $ memoryLimit !== -1 ) {
933+ // Check if a memory limit is configured and can be retrieved and determine log level if debug mode is disabled
934+ if (! $ debugModeEnabled && $ memoryLimit !== null && $ memoryLimit !== -1 ) {
931935 $ logLevel = match (true ) {
932936 $ memoryPeak > $ memoryLimit * 0.9 => ILogger::FATAL ,
933937 $ memoryPeak > $ memoryLimit * 0.75 => ILogger::ERROR ,
@@ -938,7 +942,7 @@ public static function init(): void {
938942 $ memoryLimitIni = @ini_get ('memory_limit ' );
939943 $ message = 'Request used ' . Util::humanFileSize ($ memoryPeak ) . ' of memory. Memory limit: ' . ($ memoryLimitIni ?: 'unknown ' );
940944 } else {
941- // Fall back to hardcoded thresholds if memory_limit cannot be determined
945+ // Fall back to hardcoded thresholds if memory_limit cannot be determined or if debug mode is enabled
942946 $ logLevel = match (true ) {
943947 $ memoryPeak > 500_000_000 => ILogger::FATAL ,
944948 $ memoryPeak > 400_000_000 => ILogger::ERROR ,
0 commit comments