I'm experiencing trouble with (what appears to be) memory leaks in JavaFX Scene Builder. I have filed a bug report, but in the meantime my system sometimes gets unbearably slow as Scene Builder uses 10+ GB.
As a temporary fix I want to limit the amount of memory it can use. I have tried setting the following in SceneBuilder.cfg under JVMOptions:
-XX:InitialHeapSize=256m
-XX:MaxHeapSize=256m
-XX:MaxMetaspaceSize=256m
jps
confirms the arguments are passed to the process:
3052 -Djava.library.path=/opt/SceneBuilder/app:/opt/SceneBuilder -Djava.launcher.path=/opt/SceneBuilder -Dapp.preferences.id=com/oracle/javafx/scenebuilder/app -XX:InitialHeapSize=256m -XX:MaxHeapSize=256m -XX:MaxMetaspaceSize=256m
However, the process still climbs up in memory usage, going way over 256MB, quickly surpassing 6GB and over.
So is there a way to truly limit the amount of memory used by a Java process?
Edit: I have tried using ulimit
:
ulimit -d 1024000 -v 1024000 -m 1024000
but then I'm getting an error when trying to launch:
Error occurred during initialization of VM
Could not allocate metaspace: 1073741824 bytes
which suggests Java indeed ignores the MetaspaceSize parameter. Any other way to limit memory in Java 8?