diff --git a/src/apps.js b/src/apps.js index 3c1d9590a..8df2da002 100644 --- a/src/apps.js +++ b/src/apps.js @@ -65,6 +65,7 @@ var addons = require('./addons.js'), groups = require('./groups.js'), mailboxdb = require('./mailboxdb.js'), manifestFormat = require('cloudron-manifestformat'), + os = require('os'), path = require('path'), paths = require('./paths.js'), safe = require('safetydance'), @@ -208,7 +209,7 @@ function validateMemoryLimit(manifest, memoryLimit) { assert.strictEqual(typeof memoryLimit, 'number'); var min = manifest.memoryLimit || constants.DEFAULT_MEMORY_LIMIT; - var max = (4096 * 1024 * 1024); + var max = os.totalmem() * 2; // this will overallocate since we don't allocate equal swap always (#466) // allow 0, which indicates that it is not set, the one from the manifest will be choosen but we don't commit any user value // this is needed so an app update can change the value in the manifest, and if not set by the user, the new value should be used diff --git a/webadmin/src/views/apps.js b/webadmin/src/views/apps.js index aa71c20d3..d799a4b27 100644 --- a/webadmin/src/views/apps.js +++ b/webadmin/src/views/apps.js @@ -255,7 +255,8 @@ angular.module('Application').controller('AppsController', ['$scope', '$location // create ticks starting from manifest memory limit. the memory limit here is currently split into ram+swap (and thus *2 below) // TODO: the *2 will overallocate since 4GB is max swap that cloudron itself allocates $scope.appConfigure.memoryTicks = [ ]; - for (var i = 256; i <= ($scope.config.memory*2/1024/1024); i *= 2) { + var npow2 = Math.pow(2, Math.ceil(Math.log($scope.config.memory)/Math.log(2))); + for (var i = 256; i <= (npow2*2/1024/1024); i *= 2) { if (i >= (app.manifest.memoryLimit/1024/1024 || 0)) $scope.appConfigure.memoryTicks.push(i * 1024 * 1024); } if (app.manifest.memoryLimit && $scope.appConfigure.memoryTicks[0] !== app.manifest.memoryLimit) {