Search code examples
graalvmgraaljs

How to configure js node stack size when using Graal?


I faced with problem when i try to use deep recursive function in js i get exception (RangeError: Maximum call stack size exceeded). This function perfect work out of Graal. It is only reproduced when calling polyglot Context.execute(). First call finish without exception but other throw. I use docker and graaljdk image oracle/graalvm-ce:20.0.0-java11 and use one Engine for all threads and create Context per thread. Can i increase node stack size via graal options or something else?


Solution

  • From your description, i assume you are starting Graal JS from some Java code using the polyglot API.

    Graal JS runs on the same threads as the rest of the JVM. You can increase the stack size of the JVM using the -Xss argument. For example

    $ <graalvm>/bin/java -Xss2m …
    

    2m means 2MB (i think the default on x86_64 is 1MB). You can experiment with various sizes but remember that the higher you set it, the less threads you can fit in a fixed amount of memory.