diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java index 0493e988b5..9a5fb0b1da 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java @@ -47,6 +47,7 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.internal.compiler.util.JRTUtil; import org.eclipse.jdt.internal.launching.LaunchingPlugin; import org.eclipse.osgi.service.resolver.ResolverError; import org.eclipse.pde.api.tools.internal.BundleListTargetLocation; @@ -165,6 +166,8 @@ public void aboutToRun(IJobChangeEvent event) { analyzer.dispose(); ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor()); } + JRTUtil.reset(); // reclaim space due to loaded multiple JRTUtil should better be fixed to not + // use that much space return result; } diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java index 566e32d9d5..8b0cc866f4 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java @@ -171,16 +171,22 @@ public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoFailureException("Start Framework failed!", e); } ApiAnalysisResult analysisResult; - try { - ApiAnalysis analysis = new ApiAnalysis(baselineBundles, dependencyBundles, - project.getName(), fileToPath(apiFilter), fileToPath(apiPreferences), - fileToPath(project.getBasedir()), debug, fileToPath(project.getArtifact().getFile()), - stringToPath(project.getBuild().getOutputDirectory())); - analysisResult = eclipseFramework.execute(analysis); - } catch (Exception e) { - throw new MojoExecutionException("Execute ApiApplication failed", e); - } finally { - eclipseFramework.close(); + synchronized (ApiAnalysisMojo.class) { + // due to + // https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/3885#note_1266412 we + // can not execute more than one analysis without excessive memory consumption + // unless this is fixed it is safer to only run one analysis at a time + try { + ApiAnalysis analysis = new ApiAnalysis(baselineBundles, dependencyBundles, project.getName(), + fileToPath(apiFilter), fileToPath(apiPreferences), fileToPath(project.getBasedir()), debug, + fileToPath(project.getArtifact().getFile()), + stringToPath(project.getBuild().getOutputDirectory())); + analysisResult = eclipseFramework.execute(analysis); + } catch (Exception e) { + throw new MojoExecutionException("Execute ApiApplication failed", e); + } finally { + eclipseFramework.close(); + } } log.info("API Analysis finished in " + time(start) + "."); analysisResult.resolveErrors()