Announcement Announcement Module
Collapse
No announcement yet.
java.lang.OutOfMemoryError: PermGen space Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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?


    <code>

    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 java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at my.application.batch.core.tasklet.BatchExecutor.re cordBatchRunExceptionDetails(BatchExecutor.java:10 30)
    at my.application.batch.core.tasklet.BatchExecutor.is JobRegistered(BatchExecutor.java:1003)
    at my.application.batch.core.tasklet.BatchExecutor.la unchStepJob(BatchExecutor.java:906)
    at my.application.batch.core.tasklet.BatchExecutor.ex ecute(BatchExecutor.java:341)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$ChunkTransactionCallback.doInTransaction(Tas kletStep.java:347)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:128)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:261)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:247)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:196)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:115)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:99)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    </code>

    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.

    Comment


    • #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.

      Comment


      • #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.

        Comment

        Working...
        X