Skip to content

Commit

Permalink
The Javascript runtime size can now be adjusted.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AnotherCommander committed Jul 2, 2020
1 parent 92778b7 commit c7a7f0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Core/Scripting/OOJavaScriptEngine.m
Expand Up @@ -88,6 +88,7 @@


#define OOJS_STACK_SIZE 8192
#define OOJS_RUNTIME_SIZE_MB 32


static OOJavaScriptEngine *sSharedEngine = nil;
Expand Down Expand Up @@ -278,12 +279,13 @@ - (id) init
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);
}

Expand Down

0 comments on commit c7a7f0f

Please sign in to comment.