Enonic version: 7.2.2
OS: Ubuntu 19.10
I wrote a data import endpoint, but I got a “StackOverflowError”.
Running the same code on a subset of the data worked well, so I can only conclude that a bit more memory could have allowed me to run the whole file in one go.
Can I adjust the JVM memory settings when running XP in a Sandbox?
Yes, you can experiment with JVM memory options.
For instance in powershell call
$env:JAVA_OPTS = '-Xmx4G' before
enonic sandbox start mysandbox
This will override default JAVA_OPTS for XP, so use it only for experiment or if you know what you are doing. (Current default JAVA_OPTS are quire complex and may change with any release)
But in general playing around with memory settings is a bad idea. Modern Java (Java 11) has quite decent ergonomics which rely on your hardware capabilities.
The reason that subset of data works is that probably it does not include a piece of data causing StackOverflowError. You may use
-Xss parameter to hack stack sizes, but it is even worse parameter to play with.
No, it’s not a data problem. I’m able to import all the data in batches.
What I’m thinking now, is that it isn’t a problem with the JVM-memory, but with what Nashorn gets.
It is hard to tell without data and full error.
First of all, thank you @rymsha for the feedback (and the warnings)! You rock!
I think I figured out what the issue was. I use a library (fp-ts), that has an implementation of the
IO monad that is not stack safe (no trampolining implementation). And it became an issue with a large
I was a bit reluctant to share data and the stack trace, because the “functional programming”-way to do this (with fp-ts), is very different from what most people do – and I think it might just create confusion if you aren’t familiar with the libraries.
But in my defense, I was just asking how to tweak the memory, not help to debug my problem.