@@ -915,19 +915,24 @@ 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+ $ logLevel = null ;
921+ $ debugModeEnabled = $ config ->getSystemValueBool ('debug ' , false );
922+ $ memoryLimit = null ;
920923
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 ;
924+ if (!$ debugModeEnabled ) {
925+ // Use the memory helper to get the real memory limit in bytes if debug mode is disabled
926+ try {
927+ $ memoryInfo = new \OC \MemoryInfo ();
928+ $ memoryLimit = $ memoryInfo ->getMemoryLimit ();
929+ } catch (Throwable $ e ) {
930+ // Ignore any errors and fall back to hardcoded thresholds
931+ }
927932 }
928933
929- // Check if a memory limit is configured and can be retrieved and determine log level
930- if ($ memoryLimit !== null && $ memoryLimit !== -1 ) {
934+ // Check if a memory limit is configured and can be retrieved and determine log level if debug mode is disabled
935+ if (! $ debugModeEnabled && $ memoryLimit !== null && $ memoryLimit !== -1 ) {
931936 $ logLevel = match (true ) {
932937 $ memoryPeak > $ memoryLimit * 0.9 => ILogger::FATAL ,
933938 $ memoryPeak > $ memoryLimit * 0.75 => ILogger::ERROR ,
@@ -938,7 +943,7 @@ public static function init(): void {
938943 $ memoryLimitIni = @ini_get ('memory_limit ' );
939944 $ message = 'Request used ' . Util::humanFileSize ($ memoryPeak ) . ' of memory. Memory limit: ' . ($ memoryLimitIni ?: 'unknown ' );
940945 } else {
941- // Fall back to hardcoded thresholds if memory_limit cannot be determined
946+ // Fall back to hardcoded thresholds if memory_limit cannot be determined or if debug mode is enabled
942947 $ logLevel = match (true ) {
943948 $ memoryPeak > 500_000_000 => ILogger::FATAL ,
944949 $ memoryPeak > 400_000_000 => ILogger::ERROR ,
0 commit comments