Question

I'm getting PermGen space errors when running rake assets:precompile under jruby 1.7.4. I've tried increasing MaxPermSize and turning on ClassUnloading, to no avail.

This is happening reliably, both on a Cloudbees m1-large instance and locally on my macbook pro.

$ MAVEN_OPTS='-XX:MaxPermSize=2048M -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -w' bundle exec rake dash:build RAILS_ENV=production --trace
** Invoke environment (first_time)
** Execute environment
** Invoke dash:build (first_time)
** Invoke dash:prebuild (first_time)
** Execute dash:prebuild
** Invoke assets:clean (first_time)
** Execute assets:clean
** Invoke assets:clean:all (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:clean:all
rm -rf /Users/andrew/code/unified_dashboard/public/assets
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment
** Invoke tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
PermGen space
org.jruby.java.proxies.JavaProxy.confirmCachedProxy(JavaProxy.java:503)
org.jruby.java.proxies.JavaProxy.getSingletonClass(JavaProxy.java:495)
org.jruby.RubyModule.extend_object(RubyModule.java:2008)
org.jruby.RubyModule$INVOKER$i$1$0$extend_object.call(RubyModule$INVOKER$i$1$0$extend_object.gen)
org.jruby.RubyClass.finvoke(RubyClass.java:741)
org.jruby.runtime.Helpers.invoke(Helpers.java:477)
org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:359)
org.jruby.RubyBasicObject.extend(RubyBasicObject.java:2756)
org.jruby.RubyKernel.extend(RubyKernel.java:2187)
org.jruby.RubyKernel$INVOKER$s$0$0$extend.call(RubyKernel$INVOKER$s$0$0$extend.gen)
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:662)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:205)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:168)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.IfNode.interpret(IfNode.java:118)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:225)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:202)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:202)
org.jruby.ast.FCallTwoArgNode.interpret(FCallTwoArgNode.java:38)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueBodyNode.interpret(RescueBodyNode.java:108)
org.jruby.ast.RescueNode.handleJavaException(RescueNode.java:205)
org.jruby.ast.RescueNode.interpret(RescueNode.java:138)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:225)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:202)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)

As far as I know the project isn't doing anything unusual with its assets. I'm not very familiar with Java or Jruby (I inherited the project when the maintainer quit) so I've run out of ideas for things to investigate. I'd sure appreciate some help!

Was it helpful?

Solution

You are setting MAVEN_OPTS, but you aren't executing Maven, so nothing is going to care about that environment variable. You are ultimately trying to set the JVM option, and the easiest way in this case is via JRUBY_OPTS:

$ JRUBY_OPTS='-J-XX:MaxPermSize=1G' ruby -e 'puts java.lang.management.ManagementFactory.getMemoryPoolMXBeans.map {|p| "#{p.name}: #{p.usage.max}"}'
PS Perm Gen: 1073741824

$ JRUBY_OPTS='-J-XX:MaxPermSize=2G' ruby -e 'puts java.lang.management.ManagementFactory.getMemoryPoolMXBeans.map {|p| "#{p.name}: #{p.usage.max}"}'
PS Perm Gen: 2147483648
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top