Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Out of memory error #19

Closed
geraldus opened this issue Nov 7, 2014 · 6 comments
Closed

Out of memory error #19

geraldus opened this issue Nov 7, 2014 · 6 comments

Comments

@geraldus
Copy link

geraldus commented Nov 7, 2014

I'm facing out of memory error on my laptop running OS X Yosemite with 16 gigabyte of RAM.
I've intentded to compile my javascript app (172k lines). I've tried both SIMPLE_OPTIMIZATION and ANDVANCED_OPTIMIZATION.

My question on StackOverflow

Output listing:

$ ccjs ./static/ui.jsexe/all.js --compilation_level=ADVANCED_OPTIMIZATIONS > ./static/ui.jsexe/all.min.js                                                                              
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2245)
        at java.util.Arrays.copyOf(Arrays.java:2219)
        at java.util.ArrayList.grow(ArrayList.java:213)
        at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:187)
        at java.util.ArrayList.add(ArrayList.java:411)
        at com.google.javascript.jscomp.parsing.NewIRFactory.<init>(NewIRFactory.java:241)
        at com.google.javascript.jscomp.parsing.NewIRFactory.transformTree(NewIRFactory.java:289)
        at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:106)
        at com.google.javascript.jscomp.JsAst.parse(JsAst.java:84)
        at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:50)
        at com.google.javascript.jscomp.CompilerInput.getAstRoot(CompilerInput.java:118)
        at com.google.javascript.jscomp.Compiler.hoistNoCompileFiles(Compiler.java:1500)
        at com.google.javascript.jscomp.Compiler.parseInputs(Compiler.java:1404)
        at com.google.javascript.jscomp.Compiler.parse(Compiler.java:788)
        at com.google.javascript.jscomp.Compiler.compileInternal(Compiler.java:743)
        at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:93)
        at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:655)
        at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:652)
        at com.google.javascript.jscomp.Compiler$4.call(Compiler.java:699)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
@dcodeIO
Copy link
Owner

dcodeIO commented Nov 7, 2014

This error comes from closure compiler itself, it's thrown on the Java side of things (more memory allocated than available to the JVM). As a workaround, you could try to edit the default arguments to contain -Xms and -Xmx options, e.g. -Xms256m -Xmx1024m.

From the docs:

  • The -Xms option sets the initial and minimum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection.
  • This option sets the maximum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection. Depending upon the kind of operating system you are running, the maximum value you can set for the Java heap can vary.

Please let me know of your findings!

@geraldus
Copy link
Author

geraldus commented Nov 7, 2014

Cool! It helped! I'm not certain should that options be set by default, maybe adding command line arguments which allow such customisations would be right thing to do.
Thank you!

@dcodeIO
Copy link
Owner

dcodeIO commented Nov 7, 2014

Thanks, that was also my thought. I think I'll go with some reasonable defaults plus giving an option to adapt it.

@geraldus
Copy link
Author

geraldus commented Nov 7, 2014

I'll close this for now, thanks again!

@carlitux
Copy link

hey I set
export JVM_ARGS="-Xmx8048m -XX:MaxPermSize=2048m"
and still getting same error

@toddpi314
Copy link

@carlitux Xmx: This value must be a multiple of 1024 greater than 2MB

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants