aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-12-18 12:31:09 +0100
committerJoas Schilling <coding@schilljs.com>2024-12-18 12:31:09 +0100
commit14aab1f2aef5a301447287c56a49f8cbe0d4e355 (patch)
tree3442ce91b24457d285dbb81277796a447c7ed7eb
parent407ac7f739a7cb2136fa717b06c9163b05f36def (diff)
downloadnextcloud-server-perf/log-excessive-memory-consumption.tar.gz
nextcloud-server-perf/log-excessive-memory-consumption.zip
perf: Log excessive memory usage on normal requestsperf/log-excessive-memory-consumption
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--index.php7
-rw-r--r--ocs/v1.php7
2 files changed, 14 insertions, 0 deletions
diff --git a/index.php b/index.php
index f3ed07c3572..04dbe104dc0 100644
--- a/index.php
+++ b/index.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
*/
require_once __DIR__ . '/lib/versioncheck.php';
+$memoryBefore = memory_get_usage();
use OC\ServiceUnavailableException;
use OC\User\LoginException;
@@ -104,4 +105,10 @@ try {
throw $ex;
}
OC_Template::printExceptionErrorPage($ex, 500);
+} finally {
+ $memoryAfter = memory_get_usage();
+ if ($memoryAfter - $memoryBefore > 400_000_000) {
+ $message = 'Used memory was more than 400 MB: ' . \OCP\Util::humanFileSize($memoryAfter - $memoryBefore);
+ \OCP\Server::get(LoggerInterface::class)->warning($message);
+ }
}
diff --git a/ocs/v1.php b/ocs/v1.php
index 7205f4a26b7..c1db0f44c1b 100644
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
*/
require_once __DIR__ . '/../lib/versioncheck.php';
+$memoryBefore = memory_get_usage();
require_once __DIR__ . '/../lib/base.php';
use OC\OCS\ApiHelper;
@@ -70,4 +71,10 @@ try {
// Just to be save
}
ApiHelper::respond(OCSController::RESPOND_SERVER_ERROR, $txt);
+} finally {
+ $memoryAfter = memory_get_usage();
+ if ($memoryAfter - $memoryBefore > 400_000_000) {
+ $message = 'Used memory was more than 400 MB: ' . \OCP\Util::humanFileSize($memoryAfter - $memoryBefore);
+ \OCP\Server::get(LoggerInterface::class)->warning($message);
+ }
}