Make verilog java.lang.OutOfMemoryError

[info] Compiling 23 Scala sources to /home/utest/sifive/freedom/rocket-chip/hardfloat/target/scala-2.11/classes…
[warn] there were 492 feature warnings; re-run with -feature for details
[warn] one warning found
[info] Compiling 169 Scala sources to /home/utest/sifive/freedom/rocket-chip/target/scala-2.11/classes…
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.get(

[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
[error] Use ‘last’ for the full log. recipe for target ‘/home/utest/sifive/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.fir’ failed
make: *** [/home/utest/sifive/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.fir] Error 1

I run it in the virtualbox, the mem limit is 1024MB. The java version is the latest jdk1.8.0_131 from oracle. What should I do?

The java.lang.OutOfMemoryError: Java heap space error will be triggered when the application attempts to add more data into the heap space area, but there is not enough room for it.

Run Java with the command-line option -Xmx, which sets the maximum size of the heap.

Increasing the heap size is not a “fix” it is a “plaster”, 100% temporary. It will crash again in somewhere else. To avoid these issues, write high performance code.

  • Use local variables wherever possible.
  • Make sure you select the correct object (EX: Selection between String, StringBuffer and StringBuilder)
  • Use a good code system for your program(EX: Using static variables VS non static variables)
  • Other stuff which could work on your code.
  • Try to move with multy THREADING

Thanks @nickwelhar for the tips! Feel free to file a PR/issue on the open source repos where these issues are encountered.

java.lang.OutOfMemoryError: Java heap space

Java heap space is created, when the application loads up. If for some reason your application is not making old unused objects available to the garbage collector, all these objects are going to consume this limited available space leaving no space for new objects. Hence, when a new object creation request comes in, JVM throws the OutOfMemoryError.

Also, in a typical web application scenario, if your application’s traffic increases dramatically, it is going to consume all the available memory to serve these flooded requests. Hence, there will be a time when there won’t be any memory available to support new requests and your application may crash for the OutOfMemoryError.

How do you prevent the Java.lang.OutOfMemoryError?

Either make your program more efficient or allocate more RAM to Java.

If the program is already as efficient as it can be and you have a program that requires a lot of RAM, then just allocate some more to Java in the settings. If you computer doesn’t have enough RAM, then I suggest getting a better computer or putting more RAM in your existing computer.

However, the most likely scenario is that you’re just performing your task in an inefficient way, like using a bunch of different data structures when you could use one. Try to compact your code before you do option 1.