I get the following exception in my Jenkins job:-
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:201)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:149)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:86)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
......
I run my Junit test cases in this job through Maven. As suggested by Jenkins I have a new global property MAVEN_OPTS
with a value as high as -XX:MaxPermSize=1024m
.
But still I continue to get the java.lang.OutOfMemoryError: PermGen
.
Any assistance is greatly appreciated.
Thanks Stefan for your answer. Unfortunately adding the default log4j classloader did not solve my issue. However the link provided by you solved the issue.
I had to add the following configuration in my "maven-surefire-plugin" definition:-
<argLine>-XX:PermSize=512m -XX:MaxPermSize=1024m</argLine>
This has fixed my problem.
PowerMock has a memory leak caused by class loading stuff: https://code.google.com/p/powermock/issues/detail?id=346
You can use the default classloader for the log4j classes:
@RunWith(PowerMockRunner.class)
@PowerMockIgnore(value = {"org.apache.log4j.*"})
public class YourTest {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With