Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for possible ApiTools leak #2963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading