Monday, August 31, 2015

heap memory consumption by CrossSiteIframeLinker

Hello,

I'm meeting a problem during gwt compilation. My application is quite big.

[INFO]  
Permutation 8 (strong name BA14D66EEC73FB44262423A88ADFC40E) has an initial download size of 19984060 and total script size of 37457074

[INFO]   Invoking Linker RPC policy file manifest

[INFO]    Invoking Linker Cross-Site-Iframe

[INFO]       [ERROR] Failed to link

[INFO] java.lang.OutOfMemoryError: Java heap space

[INFO]  at java.util.Arrays.copyOf(Arrays.java:2367)

[INFO]  at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)

[INFO]  at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)

[INFO]  at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)

[INFO]  at java.lang.StringBuilder.append(StringBuilder.java:132)

[INFO]  at com.google.gwt.core.linker.CrossSiteIframeLinker.wrapPrimaryFragment(CrossSiteIframeLinker.java:700)

[INFO]  at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.generatePrimaryFragmentString(SelectionScriptLinker.java:406)

[INFO]  at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.generatePrimaryFragment(SelectionScriptLinker.java:377)

[INFO]  at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.doEmitCompilation(SelectionScriptLinker.java:254)

[INFO]  at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.link(SelectionScriptLinker.java:196)

[INFO]  at com.google.gwt.core.ext.linker.impl.StandardLinkerContext.invokeLinkForOnePermutation(StandardLinkerContext.java:381)

[INFO]  at com.google.gwt.dev.Link.finishPermutation(Link.java:489)

[INFO]  at com.google.gwt.dev.Link.doSimulatedShardingLink(Link.java:450)

[INFO]  at com.google.gwt.dev.Link.link(Link.java:182)

[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:246)

[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:158)

[INFO]  at com.google.gwt.dev.Compiler$1.run(Compiler.java:120)

[INFO]  at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)

[INFO]  at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)

[INFO]  at com.google.gwt.dev.Compiler.main(Compiler.java:127)

[INFO]  [ERROR] Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)

[INFO] Shutting down PersistentUnitCache thread


The problem appears while appending String using a StringBuilder which size is not initialized. As permutations size is huge, I guess it would work better (needing less heap) if the initial StringBuilder size was initialized with a big value (in code or through a parameter). 

AbstractStringBuilder : 

void
expandCapacity(int minimumCapacity) {
         int newCapacity = (. + 1) * 2;
         if (newCapacity < 0) {
             newCapacity = .;
         } else if (minimumCapacity > newCapacity) {
             newCapacity = minimumCapacity;
         }
          = Arrays.copyOf(, newCapacity); <-- value exists twice here, doubling memory consumption.
     }


If permutation size is known before entering in CrossSiteIframeLinker, I think StringBuilder should be initialized correctly. I don't even mention the number of array copies needed to allocate several Mb by starting from 16 bytes to final size.

What do you think of it ?
Thank you.
dominique

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment