Hello everybody,i have a problem need your help,I'm very appreciate that you can help me to fix it.
Details:
......
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
at com.sun.tools.javac.util.ArrayUtils.ensureCapacity(ArrayUtils.java:60)
at com.sun.tools.javac.util.SharedNameTable.fromUtf(SharedNameTable.java:130)
at com.sun.tools.javac.util.Names.fromUtf(Names.java:342)
at com.sun.tools.javac.util.ByteBuffer.toName(ByteBuffer.java:159)
at com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.toName(ClassWriter.java:328)
at com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.access$300(ClassWriter.java:273)
at com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:343)
at com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:624)
at com.sun.tools.javac.jvm.ClassWriter.writeField(ClassWriter.java:1091)
at com.sun.tools.javac.jvm.ClassWriter.writeFields(ClassWriter.java:1591)
at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1691)
at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1621)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:746)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
Compiling Bazel Java code...
There are my environment:
Platform:
Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) i686 GNU/Linux
java version:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) Server VM (build 25.91-b14, mixed mode)
java -XshowSettings:vm
VM settings:
Max. Heap Size (Estimated): 437.50M
Ergonomics Machine Class: server
Using VM: Java HotSpot(TM) Server VM
The javac's heap size is 256m in the Java Visual VM.
I had tried every way as I could.
Thanks very much!
I find the way to fix this problem:
vim scripts/bootstrap/compile.sh
find the "_run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}"_" and add
-J-Xms256m -J-Xmx384m
as
" _run "${JAVAC}" -J-Xms256m -J-Xmx384m -classpath "${classpath}" -sourcepath "${sourcepath}"_"
and it works well.
Thanks, that's awesome!
Hi everyone!
The previous answer helped me in the begging of compilation, but in the very end I get the same again even with extra options. The error code:
ERROR: /home/iwi/bazel/src/main/java/com/google/devtools/build/lib/standalone/BUILD:5:1: Java compilation in rule '//src/main/java/com/google/devtools/build/lib/standalone:standalone' failed: Worker process sent response with exit code: 1.
An exception has occurred in the compiler (9-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3520)
at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1069)
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:390)
at com.sun.tools.javac.file.JavacFileManager$ArchiveContainer.<init>(JavacFileManager.java:501)
at com.sun.tools.javac.file.JavacFileManager.getContainer(JavacFileManager.java:310)
at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:692)
at com.sun.tools.javac.code.ClassFinder.scanPlatformPath(ClassFinder.java:590)
at com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:511)
at com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:294)
at com.sun.tools.javac.code.ClassFinder.access$000(ClassFinder.java:73)
at com.sun.tools.javac.code.ClassFinder$1.complete(ClassFinder.java:165)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:590)
at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:299)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:509)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:255)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:270)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:485)
at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:932)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:815)
at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:104)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder$1.invokeJavac(SimpleJavaLibraryBuilder.java:163)
at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:52)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:166)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:178)
Target //src:bazel failed to build
INFO: Elapsed time: 1646.645s, Critical Path: 1382.24s
Hello,
I know this is an old post but I tried what @JaidenChiang did and still had a "system out of resources" message. @JaidenChiang still got it right! I only had to add this to his line edit: _-J-Xms512m_ and it works now, the edited line becomes like:
_run "${JAVAC}" -J-Xms256m -J-Xmx384m 鈥揓-Xms512m -classpath "${classpath}" -sourcepath "${sourcepath}_
Hope this helps those who encountered something similar to what I had :)
Sorry to leave a comment on a closed issue and bother everyone, but with the commit 09222fac in place, it is now possible to set up an environment variable and insert extra javac options, like this:
env BAZEL_JAVAC_OPTS="-J-Xms384m -J-Xmx512m" bash ./compile.sh
Most helpful comment
I find the way to fix this problem:
vim scripts/bootstrap/compile.sh
find the "_run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}"_" and add
-J-Xms256m -J-Xmx384m
as
" _run "${JAVAC}" -J-Xms256m -J-Xmx384m -classpath "${classpath}" -sourcepath "${sourcepath}"_"
and it works well.