Skip to content

Conversation

@arunjose696
Copy link
Contributor

@arunjose696 arunjose696 commented Jul 21, 2025

Description:

Each Operation subclass now maintains its own list of disposable SWT resources. These are added to a disposables list within the Operation and are disposed when the GC is disposed. This ensures cleanup of resources.

Steps to Reproduce:

There is currently an issue with SWT resource tracking due to monitor-specific scaling. To reproduce the warning:

1)Temporarily comment out resourcesWithZoomSupport.add(resource); in the Device class (i.e., the implementation of registerResourceWithZoomSupport):

2)Start the Eclipse runtime workspace with the following VM argument:

-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
3)Wait a minute for the garbage collector to run.

You will then see the following warning in the logs:

!ENTRY org.eclipse.ui.ide 4 4 2025-07-22 10:57:59.955
!MESSAGE Not properly disposed SWT resource
!STACK 0 
java.lang.Error: SWT Resource was not properly disposed

@github-actions
Copy link
Contributor

github-actions bot commented Jul 21, 2025

Test Results

   546 files  ±0     546 suites  ±0   36m 33s ⏱️ +4s
 4 407 tests ±0   4 390 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 713 runs  ±0  16 586 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 999d3db. ± Comparison against base commit 69a577c.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

Overall, the proposal looks great. Maybe can further improve the temporary resource handling in a follow-up by only storing the resource's data and creating new resources only temporarily on demand, but this already properly addresses potentialy resource leaks, so let's start with this proposal.

Copy link
Contributor

@amartya4256 amartya4256 left a comment

Choose a reason for hiding this comment

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

I tested the code. For all the Operations, a disposable resource is registered, are all disposed on the disposal of the GC. However, I have one concern over Region.
For Region, we do not store the region object but the handle for the zoom. Which means if the GC is refreshed with a different zoom, the same handle will be used. Probably not related to this PR, but maybe we need to check if we would run in a problem with that.

Looks good. Approving.

Each Operation subclass now maintains its own list of disposable SWT
resources. These are added to a `disposables` list within
the Operation and are disposed when the GC is disposed. This ensures
cleanup of resources.
@HeikoKlare HeikoKlare force-pushed the arunjose696/362/trackAndDisposeResources branch from 28f8835 to 999d3db Compare July 22, 2025 11:26
@HeikoKlare HeikoKlare merged commit 239428b into eclipse-platform:master Jul 22, 2025
17 checks passed
@HeikoKlare HeikoKlare deleted the arunjose696/362/trackAndDisposeResources branch July 22, 2025 11:39
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.

Track and dispose resources created by operations in GC

3 participants