January 29, 2014

Out Of Memory Errors During The OSB Build

OEPE builds take a long time and sometimes, for large domains, fail with OutOfMemory errors.

Turns out this is not a heap OOM, but a PermGen space one.

[java] Exporting to /srvrs/esb_tp/build/output/paypal2/paypal2-sbconfig-140122-212239.jar...
[java] Exception in thread "Worker-4"
[java] Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Worker-4"
[java] Exception in thread "Worker-1"
[java] Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Worker-1"

The setup is complicated by the fact that the launcher started from build.xml is not the JVM that actually does the build; launcher launches (duh) OEPE for this task, and so setting parameters to Ant’s java task does not help.

At first I failed to find a correct set of parameters to pass to build, and resorted to hacks. I have renamed java binary under JRE into java.native, and created a shell file named “java” instead:

exec /builds/jdk1.7/jre/bin/java.native -XX:MaxPermGen=1024m $*

which worked remarkably well - not only OOMs were gone, but the build time reduced from 8 minutes to 4.

The solution is somewhat unsatisfactory though, and later our release management team offered a better option: put the following lines into the build.xml script:

<jvmarg value="-Xms512m"></jvmarg>;
<jvmarg value="-Xmx1024m"></jvmarg>;
<jvmarg value="-XX:PermSize=128m"></jvmarg>;
<jvmarg value="-XX:MaxPermSize=512m"></jvmarg>;

For the record, the complete build step now looks like this:

<java fork="true" failonerror="true" maxmemory="2000m" jar="${oepe.home}/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" classpathref="library.osb" dir="${oepe.home}">
  <arg line="-data ${workspace.dir}"></arg>
  <arg line="-application com.bea.alsb.core.ConfigExport"></arg>
  <arg line="-configProject ${config.project}"></arg>
  <arg line="-configJar ${output.dir}/${profilename}-${config.jar.name}-${label}.jar"></arg>
  <arg line="-includeDependencies true"></arg>
  <arg line="-configuration ${output.dir}"></arg>
  <sysproperty value="${weblogic.home}" key="weblogic.home"></sysproperty>
  <sysproperty value="${alsb.home}" key="osb.home"></sysproperty>
  <sysproperty value="true" key="com.bea.plateng.common.util.logging.useJDKlogger"></sysproperty>
  <sysproperty value="1000" key="osgi.bundlefile.limit"></sysproperty>
  <sysproperty value="${alsb.home}/harvester" key="harvester.home"></sysproperty>
  <sysproperty value="en_US" key="osgi.nl"></sysproperty>
  <sysproperty value="true" key="sun.lang.ClassLoader.allowArraySyntax"></sysproperty>
  <sysproperty value="${bea.home}" key="middleware.home"></sysproperty>
  <sysproperty value="/srvrs/esb_tp/tmp" key="java.io.tmpdir"></sysproperty>
  <jvmarg value="-Xms512m"></jvmarg>
  <jvmarg value="-Xmx1024m"></jvmarg>
  <jvmarg value="-XX:PermSize=128m"></jvmarg>
  <jvmarg value="-XX:MaxPermSize=512m"></jvmarg>

Note that output directory and its sibling p2/ directory are removed before the build, but in our setup it is done by the *.sh file. You may want to do it too.

Vladimir Dyuzhev, author of GenericParallel

About Me

My name is Vladimir Dyuzhev, and I'm the author of GenericParallel, an OSB proxy service for making parallel calls effortlessly and MockMotor, a powerful mock service.

I'm building SOA enterprise systems for clients large and small for almost 20 years. Most of that time I've been working with BEA (later Oracle) Weblogic platform, including OSB and other SOA systems.

Feel free to contact me if you have a SOA project to design and implement. See my profile on LinkedIn.

I live in Toronto, Ontario, Canada.  canada   Email me at info@genericparallel.com