mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
perf: Log excessive memory usage on normal requests
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
407ac7f739
commit
14aab1f2ae
2 changed files with 14 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue