title: Handling PermGen errors in ant bpelc task
body: <p>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.</p>
  
  <p>Usually this relates to the MaxPermSize allocated to the JVM. Irakli Nadareishvili has one of the <a href="http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space" rel="nofollow noreferrer">best explanations of PermGen errors</a> and guide to setting <a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp#PerformanceTuning" rel="nofollow noreferrer">Java HotSpot VMOptions</a> (e.g. -XX:MaxPermSize=128M)</p>
  
  <p>In this case, I quickly narrowed the issue down to a particular <a href="http://ode.apache.org/bpelc-task.html" rel="nofollow noreferrer">bpelc</a> ant task </p>
  
  <pre><code>&lt;bpelc input="${build.dir}/bpel/bpel.xml" 
  out="${build.dir}/output" rev="${version}" home="${bpel.home}"/&gt;
  </code></pre>
  
  <p>Now I don't think bpelc takes the compilerarg element like javac:</p>
  
  <pre><code>  &lt;javac srcdir="${src.dir}"
           destdir="${classes.dir}"
           classpathref="libraries"&gt;
      &lt;compilerarg value="-XX:MaxPermSize=128M"/&gt;
    &lt;/javac&gt; 
  </code></pre>
  
  <p>So how to fix the error for the bpelc task? The best solution I've come up with so far is to set the <a href="http://ant.apache.org/manual/running.html#envvars" rel="nofollow noreferrer">ANT_OPTS</a> environment variable. This seems to have avoided the problem to date.</p>
  
  <pre><code>export ANT_OPTS=-XX:MaxPermSize=128m
  </code></pre>
  
  <p>Can anyone shed more light? Is that a sure-fire fix?</p>