aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/MemoryInfo.php
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-08-04 21:53:50 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-08-20 15:24:10 +0200
commitc164409ee7f921a96f95e1fe95d86fe07a98963e (patch)
tree42fc9ded3b31d152242258518366da0c145b570d /lib/private/MemoryInfo.php
parent1d2bc9c45ecbbb7521dbf14dba6560d925691f01 (diff)
downloadnextcloud-server-c164409ee7f921a96f95e1fe95d86fe07a98963e.tar.gz
nextcloud-server-c164409ee7f921a96f95e1fe95d86fe07a98963e.zip
Adds a memory limit warning for console commands if the limit is below the recommended value
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'lib/private/MemoryInfo.php')
-rw-r--r--lib/private/MemoryInfo.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/MemoryInfo.php b/lib/private/MemoryInfo.php
index 14865ed682e..0501d3fd049 100644
--- a/lib/private/MemoryInfo.php
+++ b/lib/private/MemoryInfo.php
@@ -6,6 +6,19 @@ namespace OC;
* Helper class that covers memory info.
*/
class MemoryInfo {
+
+ const RECOMMENDED_MEMORY_LIMIT = 512 * 1024 * 1024;
+
+ /**
+ * Tests if the memory limit is greater or equal the recommended value.
+ *
+ * @return bool
+ */
+ public function isMemoryLimitSufficient(): bool {
+ $memoryLimit = $this->getMemoryLimit();
+ return $memoryLimit === -1 || $memoryLimit >= self::RECOMMENDED_MEMORY_LIMIT;
+ }
+
/**
* Returns the php memory limit.
*