Announcement Announcement Module
No announcement yet.
java.lang.OutOfMemoryError: PermGen space Issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.OutOfMemoryError: PermGen space Issue

    Hi All,

    We have batch that run for 10 hours contains more than 150 jobs.
    Our application registers the job individually and run begins.
    once the job is completed,we Unregister the job.
    Nearly 85 to 90 jobs got completed the below exception is thrown.

    we are trying to increase the Permanent Generation (-XX:MaxPermSize=128m).

    But Still i have some doubts.
    1. We were not unregistering the job before. Is it a cause for the exception ?
    ( But, we tried with unregistering too.Then too we ended up in the same exception)

    2. Any other way to avoid this error other than increasing the memory?


    ERROR org.springframework.batch.core.step.AbstractStep - Encountered an error executing the step
    java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at n Source)
    at Source)
    at$000(Unknown Source)
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at cordBatchRunExceptionDetails( 30)
    at JobRegistered(
    at unchStepJob(
    at my.application.batch.core.tasklet.BatchExecutor.ex ecute(
    at org.springframework.batch.core.step.tasklet.Taskle tStep$ChunkTransactionCallback.doInTransaction(Tas
    at nTemplate.execute(
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe
    at plate.getNextResult(
    at plate.executeInternal(
    at plate.iterate(
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(
    at org.springframework.batch.core.step.AbstractStep.e xecute(
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(
    at ate.StepState.handle(
    at mpleFlow.resume(
    at mpleFlow.start(
    at Execute(
    at org.springframework.batch.core.job.AbstractJob.exe cute(

    Thanks for your reply in advance.

  • #2
    The PermGen space is where the JVM stores the definition of classes, sometimes it gets full because of applications that uses lots of third party frameworks and libs. I guess it can get also get full if applications generate lots of dynamic classes (proxys and so on). You should perhaps try to monitor the PermGen space with a tool like jconsole or jvisualvm.

    Don't feel bad if you increase the size, especially if the batch jobs are running in a container that hosts many applications. Start to worry if you still get the exception after several increases (128 Mo is quite big, but not excessive).

    I don't see why the unregistration of the job would cause the exception, but we never know.


    • #3
      Thanks for your reply arno.
      I have tried by increasing the PermGen space ( -XX:MaxPermSize=384m). It is working fine.
      I will try to monitor using jconsole or jvisualvm.


      • #4
        I met similar issue. That is because spring-batch call ConfigurableApplicationContext.refresh() before run a job. It will load duplicated proxy classes when using cglib. You can add -XX:+TraceClassLoading -XX:+TraceClassUnloading to JVM parameters add look at the system.out console to check it.
        My solution is
        (1) add perm size
        (2) using JDK proxy instead of Cglib.