Profiling your Scala / Java / JVM memory with VisualVM
My first app in Scala it is crushed after 15 min with out of heap space error.
So, I was curious what can I do to avoid it. May be it is wrong scala
Obviously, I need to specify some memory constraints for your app and here is way how to do it.
Scala app recognize JAVA_OPTS environment variable and using it to start JVM
export JAVA_OPTS=”-mx1024m -ms1024m”
Then jsut start
scala -classpath classes org.dimetron.lib.LibraryZipFilesIndexer | tee index.txt
But how to be sure it is not a memory leak etc ?
Answer is easy - Use VisualVM. It is distributed as part of Oracle JDK
To start it just type jvisualvm
Here is nice screenshot of running example,
where you can see Heap size and estimate required memory for your app.
In my case 1024M is good option :))
