Skip to content

GWT compiler issues - OutOfMemoryError on 64bit machine with massive gwt app #7188

@dankurka

Description

@dankurka

Originally reported on Google Code with ID 7191

Hi.

My team has massive gwt app. We have problem compiling it to production.
Our (one of tree) biggest, main module generates 70 permutations. In each permutation
we have 130 split points.
Gwt compiler when splitting permutation into separate javascript files requires huge
amount of memory. 

We first were compiling it on machine:
- windows server 2003 32 bit
- 4 GB of ram
- 4 cores 2.4 GHz

We run compile as part of ant file with this macrodef
<macrodef name="gwtCompile">
        <attribute name="module" />
        <attribute name="classpathref" />
        <sequential>
            <java classpathref="@{classpathref}" classname="com.google.gwt.dev.Compiler" fork="true"
maxmemory="896m">
                <arg value="@{module}" />
                <arg value="-war" />
                <arg value="${dir.result.name}" />
                <arg value="-style" />
                <arg value="OBF" />
                <arg value="-localWorkers" />
                <arg value="1" />
            </java>
        </sequential>
    </macrodef>


It took about 140 minutes, but compiled ok. We wanted to switch to 64 bit since jvm
heap size limitations in Win 32bit.

So we set up machine:
- windows server 2008 64 bit R2
- 6 GB of ram
- 4 cores 2.4 GHz

We changed a little bit compile macrodef:
<macrodef name="gwtCompile">
        <attribute name="module" />
        <attribute name="classpathref" />
        <sequential>
            <java classpathref="@{classpathref}" classname="com.google.gwt.dev.Compiler" fork="true">
                <arg value="@{module}" />
                <arg value="-war" />
                <arg value="build/war" />
                <arg value="-style" />
                <arg value="OBF" />
                <arg value="-localWorkers" />
                <arg value="1" />

                <jvmarg value="-Xms256m"/>
                <jvmarg value="-Xmx1024m"/>
                <jvmarg value="-XX:MaxPermSize=64m"/>
                <jvmarg value="-XX:+UseConcMarkSweepGC"/>
            </java>
        </sequential>
    </macrodef>

But on new machine compilation fails. It compiles only when we set Xmx above 1400m.
The error is:
 [java]             Compiling permutation 2...
     [java]       [ERROR] OutOfMemoryError: Increase heap size or lower gwt.jjs.maxThreads
     [java] java.lang.OutOfMemoryError: Java heap space
     [java]     at java.util.HashMap.resize(HashMap.java:462)
     [java]     at java.util.HashMap.addEntry(HashMap.java:755)
     [java]     at java.util.HashMap.put(HashMap.java:385)
     [java]     at java.util.HashSet.add(HashSet.java:200)
     [java]     at com.google.gwt.dev.jjs.impl.ControlFlowAnalyzer$RescueVisitor.visit(ControlFlowAnalyzer.java:495)
     [java]     at com.google.gwt.dev.jjs.ast.JStringLiteral.traverse(JStringLiteral.java:62)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:144)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.acceptImmutable(JVisitor.java:152)
     [java]     at com.google.gwt.dev.jjs.ast.JMethodCall.visitChildren(JMethodCall.java:250)
     [java]     at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:241)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:125)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:120)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
     [java]     at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:79)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:125)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:120)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
     [java]     at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:81)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:125)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:120)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
     [java]     at com.google.gwt.dev.jjs.ast.JExpressionStatement.traverse(JExpressionStatement.java:41)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:144)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.acceptWithInsertRemoveImmutable(JVisitor.java:170)
     [java]     at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:83)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:125)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:137)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:133)
     [java]     at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:82)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:125)
     [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:120)
     [java]     at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:413)
     [java]          [ERROR] Out of memory; to increase the amount of memory, use the
-Xmx flag at startup (java -Xmx128M ...)
     [java]       [ERROR] Unrecoverable exception, shutting down
     [java] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
     [java]     at com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:56)
     [java]     at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:73)
     [java]     at java.lang.Thread.run(Thread.java:619)
     [java]       [ERROR] Not all permutation were compiled , completed (1/4)
     [java]       [WARN] Lost communication with remote process
     [java] java.net.SocketException: socket closed
     [java]     at java.net.SocketInputStream.socketRead0(Native Method)
     [java]     at java.net.SocketInputStream.read(SocketInputStream.java:129)
     [java]     at java.net.SocketInputStream.read(SocketInputStream.java:182)
     [java]     at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
     [java]     at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2542)
     [java]     at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2552)
     [java]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
     [java]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
     [java]     at com.google.gwt.dev.ExternalPermutationWorkerFactory$ExternalPermutationWorker.compile(ExternalPermutationWorkerFactory.java:152)
     [java]     at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:73)
     [java]     at java.lang.Thread.run(Thread.java:619)
     [java] Java Result: 1


Are we configuring our build wrong? 
Or this is gwt compiler 'issue' to consume that big amount of memory while compiling
big apps?
How it compiles with 896m of heap on 32bit and breaks with 1024m on 64 bits?
Is this related with variable sizes on 64bit?
Is there different solution, beside extending heap size?

Im curious how much memory it takes to compile for instance AdSense gwt part.


Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):
2.4.0

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):
Not browser related.

Workaround if you have one:
Increase Compiler heap size to 1400 MB



Reported by ljaderdev on 2012-02-15 09:49:56

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions