tags:

views:

1187

answers:

1

I've been hitting a java.lang.OutOfMemoryError: PermGen error when compiling a project with ant under Linux with jdk 1.5.0_11. the same project compiles under windows without problem.

Usually this relates to the MaxPermSize allocated to the JVM. Irakli Nadareishvili has one of the best explanations of PermGen errors and guide to setting Java HotSpot VMOptions (e.g. -XX:MaxPermSize=128M)

In this case, I quickly narrowed the issue down to a particular bpelc ant task

<bpelc input="${build.dir}/bpel/bpel.xml" 
out="${build.dir}/output" rev="${version}" home="${bpel.home}"/>

Now I don't think bpelc takes the compilerarg element like javac:

  <javac srcdir="${src.dir}"
         destdir="${classes.dir}"
         classpathref="libraries">
    <compilerarg value="-XX:MaxPermSize=128M"/>
  </javac>

So how to fix the error for the bpelc task? The best solution I've come up with so far is to set the ANT_OPTS environment variable. This seems to have avoided the problem to date.

export ANT_OPTS=-XX:MaxPermSize=128m

Can anyone shed more light? Is that a sure-fire fix?

+2  A: 

When the bpelc task executes inside the original JVM running ant, then setting ANT_OPTS (or something equivalent) is the only possible solution.

One such equivalent thing might be to refactor that task to a second ant build file and run that using a separate JVM. Not really nicer, but depending on your environment it might be easier to implement.

Joachim Sauer
@saua thanks for the reinforcement! If we hit the PermGen problem again I think your suggestion of refactoring will be the next step.
tardate