The Javascript runtime size can now be adjusted.

Use the key 'JSRunTime_size_mb' in .GNUstepDefaults. The value of this key is the requested size of the JS runtime in megabytes. If the key is missing, then the default value of 32MB is used. This might be useful in the case of a lot of script-heavy (i.e. memory consuming) OXPs running.
master
AnotherCommander 2020-07-02 11:23:39 +03:00 committed by GitHub
parent 92778b72f2
commit c7a7f0f563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -88,6 +88,7 @@ MA 02110-1301, USA.
#define OOJS_STACK_SIZE 8192
#define OOJS_RUNTIME_SIZE_MB 32
static OOJavaScriptEngine *sSharedEngine = nil;
@ -278,12 +279,13 @@ static void ReportJSError(JSContext *context, const char *message, JSErrorReport
assert(sizeof(jschar) == sizeof(unichar));
// initialize the JS run time, and return result in runtime.
_runtime = JS_NewRuntime(32L * 1024L * 1024L);
uint32_t jsRuntimeInMB = [defaults oo_intForKey:@"JSRunTime_size_mb" defaultValue:OOJS_RUNTIME_SIZE_MB];
_runtime = JS_NewRuntime(jsRuntimeInMB * 1024L * 1024L);
// if runtime creation failed, end the program here.
if (_runtime == NULL)
{
OOLog(@"script.javaScript.init.error", @"%@", @"***** FATAL ERROR: failed to create JavaScript runtime.");
OOLog(@"script.javaScript.init.error", @"%@", @"***** FATAL ERROR: failed to create JavaScript runtime with size %uMB.", jsRuntimeInMB);
exit(1);
}