-1

System: Ubuntu 18.04.6 LTS, Intel Core i9-9900K, 128 GB DDR4 RAM

I am supposed to run this line:

./bin/jre/bin/java -cp lib/fcc-deploy-archive.jar de.fiskal.connector.init.UpdateCLIApplication

I get this error message after 9 seconds:

java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236) ~[?:1.8.0_275]

I tried to allocate (alot) more memory by using the -XmX like this:

./bin/jre/bin/java -Xmx64g -cp lib/fcc-deploy-archive.jar de.fiskal.connector.init.UpdateCLIApplication

How can I test if the option can be set at all? What else could be the problem here?

Railsana
  • 1,813
  • 2
  • 21
  • 30
  • Set -Xms to the same value as -Xmx. Then, the JVM will try to allocate the heap immediately. – Mihe Aug 26 '22 at 10:52
  • For long running applications, do not set -Xms the same to -Xmx, it will disable a number of heuristics that might help with performance. Also, setting -Xms to -Xmx will not prevent a OutOfMemoryError if -Xmx is too low. – Mark Rotteveel Aug 26 '22 at 10:53
  • As an aside, if the option couldn't be set, you'd receive an error. That doesn't mean that using 64g might not result in swapping or other effects bad for performance if it actually ends up using 64GiB. – Mark Rotteveel Aug 26 '22 at 10:56
  • It's not really long running. I get that error after 9 seconds. It's just an update process that has to run once somehow. – Railsana Aug 26 '22 at 10:59
  • @MarkRotteveel, do you have any sources regarding the optimization tradeoffs? I'm asking because in the past Oracle recommended to set Xms and Xmx to an equal value. – Mihe Aug 26 '22 at 11:07
  • @Mihe _"Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. However, the virtual machine is then unable to compensate if you make a poor choice."_ from https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/sizing.html – Mark Rotteveel Aug 26 '22 at 11:12
  • @MarkRotteveel, thanks. Of course, if one allocates too much, it's a bad thing. On the other hand, Oracle recommended the same value to decrease the number of GCs. – Mihe Aug 26 '22 at 11:17
  • 2
    @Mihe The reality is more nuanced. Yes, setting them equal will avoid a number of full-gc, increase heap, full gc, increase heap, etc, but it also disables a number of tuning heuristics around sizing generations, which could result in worse performance than if you had - for example - set -Xms to half of -Xmx. – Mark Rotteveel Aug 26 '22 at 11:22

2 Answers2

0

Following is for Eclipse

Right mouse click on

Run As - Run Configuration - Arguments - Vm Arguments, then add this

-Xmx2048m

0

as stated already here you can use the -Xms and -Xmx parameters to allocate more memory to the heap of the JVM, but keep in mind that if your machine doesn't have the amount of RAM that you provided in these parameters it will not work.

DrayNeur
  • 9
  • 1
  • Thank you, I tried this (`-Xms64g -Xmx64g`) with all kind of numbers (from 512m to 64g). I still get the error message. – Railsana Aug 26 '22 at 12:16