Exception in thread "main" java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects


(Dinesh) #1

Running into this out of memory error while running

$ make -f Makefile.vc707-u500devkit verilog

on a 8GB RAM desktop.

java -Xmx2G -Xss8M -XX:MaxPermSize=256M -cp /home/dt/f/freedom/rocket-chip/firrtl/utils/bin/firrtl.jar firrtl.Driver -i /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.fir -o /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.v -X verilog
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects
at java.lang.AbstractStringBuilder.(AbstractStringBuilder.java:68)
at java.lang.StringBuilder.(StringBuilder.java:89)
at org.antlr.v4.runtime.RuleContext.getText(RuleContext.java:135)
at org.antlr.v4.runtime.RuleContext.getText(RuleContext.java:137)
at org.antlr.v4.runtime.RuleContext.getText(RuleContext.java:137)
at firrtl.Visitor.visitExp(Visitor.scala:292)
at firrtl.Visitor.$anonfun$visitExp$1(Visitor.scala:333)
at firrtl.Visitor$$Lambda$109/283318938.apply(Unknown Source)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.TraversableLike$$Lambda$70/1072601481.apply(Unknown Source)
at scala.collection.Iterator.foreach(Iterator.scala:929)
at scala.collection.Iterator.foreach$(Iterator.scala:929)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
at scala.collection.IterableLike.foreach(IterableLike.scala:71)
at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike.map(TraversableLike.scala:234)
at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at firrtl.Visitor.visitExp(Visitor.scala:333)
at firrtl.Visitor.visitStmt(Visitor.scala:268)
at firrtl.Visitor.$anonfun$visitSuite$2(Visitor.scala:150)
at firrtl.Visitor$$Lambda$112/2134607032.apply(Unknown Source)
at scala.Option.map(Option.scala:146)
at firrtl.Visitor.$anonfun$visitSuite$1(Visitor.scala:150)
at firrtl.Visitor$$Lambda$111/2005169944.apply(Unknown Source)
at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:241)
at scala.collection.TraversableLike$$Lambda$84/1459794865.apply(Unknown Source)
at scala.collection.Iterator.foreach(Iterator.scala:929)
at scala.collection.Iterator.foreach$(Iterator.scala:929)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
at scala.collection.IterableLike.foreach(IterableLike.scala:71)
common.mk:57: recipe for target ‘/home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.v’ failed
make: *** [/home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.v] Error 1$


(Dinesh) #2

Running Ubuntu 18 LTS, OpenJDK 8.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
$ type java
java is /usr/bin/java
$ java -version
openjdk version “1.8.0_191”
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)


(Dinesh) #3

Setting the paramter Xmx to 4G helps do away with the problem.

$ git diff
diff --git a/common.mk b/common.mk
index 90dba30…d2544ea 100644
— a/common.mk
+++ b/common.mk
@@ -32,7 +32,7 @@ SBT ?= java -jar $(rocketchip_dir)/sbt-launch.jar ++2.12.4

# Build firrtl.jar and put it where chisel3 can find it.
FIRRTL_JAR ?= $(rocketchip_dir)/firrtl/utils/bin/firrtl.jar
-FIRRTL ?= java -Xmx2G -Xss8M -XX:MaxPermSize=256M -cp $(FIRRTL_JAR) firrtl.Driver
+FIRRTL ?= java -Xmx4G -Xss8M -XX:MaxPermSize=256M -cp $(FIRRTL_JAR) firrtl.Driver

$(FIRRTL_JAR): $(shell find $(rocketchip_dir)/firrtl/src/main/scala -iname “*.scala”)
$(MAKE) -C $(rocketchip_dir)/firrtl SBT="$(SBT)" root_dir=$(rocketchip_dir)/firrtl build-scala

$ make -f Makefile.vc707-u500devkit verilog
java -Xmx4G -Xss8M -XX:MaxPermSize=256M -cp /home/dt/f/freedom/rocket-chip/firrtl/utils/bin/firrtl.jar firrtl.Driver -i /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.fir -o /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.v -X verilog
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Total FIRRTL Compile Time: 77195.1 ms
$


(Dinesh) #4

Setting it to 3GB also works.


java -Xmx3G -Xss8M -XX:MaxPermSize=256M -cp /home/dt/f/freedom/rocket-chip/firrtl/utils/bin/firrtl.jar firrtl.Driver -i /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.fir -o /home/dt/f/freedom/builds/vc707-u500devkit/sifive.freedom.unleashed.DevKitU500FPGADesign_WithDevKit50MHz.v -X verilog
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Total FIRRTL Compile Time: 65594.5 ms


(Bruce Hoult) #5

I’m surprised 4 GB isn’t a bit faster than 3 GB. Java, eh? Still, it’s only about a minute and you don’t do it often, so why worry?