[
https://issues.apache.org/jira/browse/SUREFIRE-1808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17255829#comment-17255829
]
Jingfei Hu commented on SUREFIRE-1808:
--------------------------------------
[~tibordigana] Thanks a lot for your reply, but i still think the call stack
should provide me some trace to root cause. And we are finally able to get a
dump of the parent process and locate where the heap is occupied. See below
screenshot.
!image-2020-12-29-13-31-31-539.png|width=533,height=134!
We can see it's an object of
org.apache.maven.plugin.surefire.booterclient.output.MultipleFailureException
which is a subclass of IOException consumes a lot of memory. And we keep
looking into what is inside of the object and find out the content is all the
logs printed out by test execution in the form of thousands of RuntimeException
objects residing the in the linked queue of MultipleFailureException. Below is
the method getLocalizedMessage of MultipleFailureException which I think
contributes to OOM though the call stack says it's line of code 204.
{code:java}
@Override
public String getLocalizedMessage()
{
StringBuilder messages = new StringBuilder();
for ( Throwable exception : exceptions )
{
if ( messages.length() != 0 )
{
messages.append( '\n' );
}
String message = exception.getLocalizedMessage();
messages.append( message == null ? exception.toString() : message );
}
return messages.toString();
}
{code}
So my question becomes
# Why do the logs printed out by tests end up with RuntimeException and
finally all being put in the linked queue of MultipleFailureException? Is it a
behavior of the forked process of TestNG or maven-surefire-plugin?
# How to workaround this? 3.0.0-M5 still has this issue.
> OutOfMemoryError running with TestNG
> ------------------------------------
>
> Key: SUREFIRE-1808
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1808
> Project: Maven Surefire
> Issue Type: Bug
> Components: Maven Surefire Plugin, TestNG support
> Affects Versions: 3.0.0-M3
> Environment: OS: Linux
> Reporter: Jingfei Hu
> Priority: Major
> Labels: OOM, TestNG, surefire
> Attachments: image-2020-06-24-14-37-45-038.png,
> image-2020-12-29-13-31-31-539.png, image-2020-12-29-13-58-44-076.png
>
>
> Hi team,
> We've been suffering OutOfMemory intermittently in our test labs recently.
> The call stack is below
> {noformat}
> [ERROR] Java heap space -> [Help 1]
> java.lang.OutOfMemoryError: Java heap space
> at java.util.Arrays.copyOf(Arrays.java:3332)
> at
> java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
> at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
> at java.lang.StringBuilder.append(StringBuilder.java:136)
> at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter$CloseableCloser.run(ForkStarter.java:204)
> at
> org.apache.maven.surefire.shade.common.org.apache.maven.shared.utils.cli.CommandLineUtils$1.call(CommandLineUtils.java:301)
> at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:615)
> at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
> at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
> at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1161)
> at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1002)
> at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:848)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229){noformat}
>
> Our test case count is +4k and still increasing, and pass rate is around 95%
> for each execution. The OOM error is not always reproducible. And we set
> memory dump parameters, but there is no dump file generated when it occurs.
> The line of code throwing the exception is below.
> !image-2020-12-29-13-58-44-076.png|width=681,height=331!
>
> More version information:
> maven-surefire-plugin: 3.0.0-M3
> testng: 6.4
> maven: 3.2.5
--
This message was sent by Atlassian Jira
(v8.3.4#803005)