diff --git a/docs/references/api.md b/docs/references/api.md index 8fed6cd95..f1e581455 100644 --- a/docs/references/api.md +++ b/docs/references/api.md @@ -152,6 +152,8 @@ If `altDomain` is set, the app can be accessed from `https://`. * `SAMEORIGIN` - allows embedding from the same domain as the app. This is the default. * `ALLOW-FROM https://example.com/` - allows this app to be embedded from example.com +`memoryLimit` is the maximum memory this app can use (in bytes) including swap. If set to 0, the app uses the `memoryLimit` value set in the manifest. If set to -1, the app gets unlimited memory. + If `readonlyRootfs` is false, then the app's rootfs can be modified post installation. This is useful for debugging as it allows the app's code to be modified post installation. Apps that have a readonly rootfs cannot be updated to a newer version (because it is not safe to update them). diff --git a/src/apps.js b/src/apps.js index b14011479..7f2df4275 100644 --- a/src/apps.js +++ b/src/apps.js @@ -207,6 +207,9 @@ function validateMemoryLimit(manifest, memoryLimit) { // 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 if (memoryLimit === 0) return null; + // a special value that indicates unlimited memory + if (memoryLimit === -1) return null; + if (memoryLimit < min) return new AppsError(AppsError.BAD_FIELD, 'memoryLimit too small'); if (memoryLimit > max) return new AppsError(AppsError.BAD_FIELD, 'memoryLimit too large'); @@ -714,7 +717,8 @@ function update(appId, data, auditSource, callback) { if (!app.readonlyRootfs && !data.force) return callback(new AppsError(AppsError.BAD_STATE, 'rootfs is not readonly')); // Ensure we update the memory limit in case the new app requires more memory as a minimum - if (values.manifest.memoryLimit && app.memoryLimit < values.manifest.memoryLimit) { + // 0 and -1 are special values for memory limit indicating unset and unlimited + if (app.memoryLimit > 0 && values.manifest.memoryLimit && app.memoryLimit < values.manifest.memoryLimit) { values.memoryLimit = values.manifest.memoryLimit; } diff --git a/src/docker.js b/src/docker.js index a6ab2b80e..14ed6d3e6 100644 --- a/src/docker.js +++ b/src/docker.js @@ -157,8 +157,7 @@ function createSubcontainer(app, name, cmd, options, callback) { // first check db record, then manifest var memoryLimit = app.memoryLimit || manifest.memoryLimit || 0; - if (developmentMode) { - // developerMode does not restrict memory usage + if (memoryLimit === -1) { // unrestricted memoryLimit = 0; } else if (memoryLimit === 0 || memoryLimit < constants.DEFAULT_MEMORY_LIMIT) { // ensure we never go below minimum (in case we change the default) memoryLimit = constants.DEFAULT_MEMORY_LIMIT;