Skip to content

Drop the builders of a project when it is closed - #3084

Open
bernd-wiswedel wants to merge 1 commit into
eclipse-platform:masterfrom
bernd-wiswedel:issue-3083-drop-builders-of-closed-projects
Open

bernd-wiswedel wants to merge 1 commit into
eclipse-platform:masterfrom
bernd-wiswedel:issue-3083-drop-builders-of-closed-projects

Conversation

@bernd-wiswedel

Copy link
Copy Markdown

A closed project kept its builders, and with them the tree of their last build. Snapshots collapse only the builder trees of open projects, so these trees kept every later workspace tree layer alive until restart: 1.4 GB of 3.6 GB live heap in my IDE. This drops the builders at the end of Project.internalClose, after the close has saved the builder state. Reopening already replaces the project with its saved tree and creates new builders from the saved state, so builds after a reopen behave as before.

The new tests in BuilderTest check that closing drops the builders, that a reopened project keeps its last built state and builds incrementally, and that a file changed while the project was closed shows up in the next build's delta.

Fixes #3083

🤖 Generated with Claude Code

@iloveeclipse

Copy link
Copy Markdown
Member

Build fails due old tycho version, probably your branch is created on too old master state. If so, please rebase and force push.

@cdietrich

Copy link
Copy Markdown
Contributor

@iloveeclipse fyi: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/work_items/8107

@iloveeclipse

Copy link
Copy Markdown
Member

@iloveeclipse fyi: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/work_items/8107

Thanks Christian, I wasn't aware.

@bernd-wiswedel : no action needed from your side. I will retrigger build once infrastructure will work again.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to release builders when projects close.

No open issues 🎉

What changed in this PR

Addresses #3083 by releasing builders when a project closes, preventing their last-built workspace trees from retaining memory while preserving saved state for reopening.

Changes:

  • Adds BuildManager.dropBuilders to clear a project’s builder instances.
  • Calls it at the end of project closure, after builder state has been saved.
  • Adds regression tests for builder release, restored incremental builds, and file changes made while closed.
File Description
resources/​tests/​org.eclipse.core.tests.resources/​src/​org/​eclipse/​core/​tests/​internal/​builders/​BuilderTest.java Tests builder cleanup and incremental-build behavior after reopening.
resources/​bundles/​org.eclipse.core.resources/​src/​org/​eclipse/​core/​internal/​resources/​Project.java Drops builders at the end of project closure.
resources/​bundles/​org.eclipse.core.resources/​src/​org/​eclipse/​core/​internal/​events/​BuildManager.java Adds a helper to clear builder instances from project build commands.

Review effort: Balanced

@iloveeclipse

Copy link
Copy Markdown
Member

@bernd-wiswedel : looks good. We are currently in 4.42 RC2 phase, and this issue, while worth fixing, doesn't qualify for RC2 candidate.

Can you please also add this small patch which should report error if we broke something internally on using the new method:

diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
index 3ac044d..c83e6f9 100644
--- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
+++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
@@ -837,5 +837,11 @@
 	 * built trees they hold. The next build instantiates the builders again from
-	 * the persisted builder state, as after a workspace restart.
+	 * the persisted builder state, as after a workspace restart. The project must
+	 * be closed before calling this method.
 	 */
 	public void dropBuilders(IProject project) {
+		if (project.isOpen()) {
+			String message = "Cannot drop builders of open project: " + project.getFullPath(); //$NON-NLS-1$
+			Policy.log(IStatus.ERROR, message, new IllegalStateException(message));
+			return;
+		}
 		ProjectDescription desc = ((Project) project).internalGetDescription();

A closed project kept its builder instances, and each builder kept the
tree of its last build. Snapshots collapse only the trees of open
projects, so such a tree kept every later workspace tree layer alive
until restart. In an IDE with 3.6 GB live heap after two days, the
builders of closed projects held 1.4 GB.

The builder state is saved with the project tree before the project is
closed, and reopening restores it from there, as after a restart. The
builder instances are of no further use, so drop them on close.

Fixes eclipse-platform#3083

Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5)
@bernd-wiswedel
bernd-wiswedel force-pushed the issue-3083-drop-builders-of-closed-projects branch from b76cbc4 to bd23b02 Compare November 23, 2026 08:03
@bernd-wiswedel

Copy link
Copy Markdown
Author

Thanks, added your check to the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closed projects keep their builders and old workspace trees in memory

4 participants