Skip to content

Conversation

HeikoKlare
Copy link
Contributor

When calling GC#drawImage(), an operation is created (like for every execution on GC) which stores the image to draw. Since the image may be disposed afterwards, a dispose listener is registered to the image, such that the image can be copied and maintained inside the operation in case of a disposal until that operation itself is disposed. The listener is currently not de-registered when disposing the GC and its operations, thus the GC operations (and thus also the containing GC) will still be referenced (as listeners from the image) until that image is disposed. Since images may be long living (or never be disposed at all), this can lead to a memory leak.

This change removes the listener from the image upon disposal of a GC and its operations such that no memory can occur.

Fixes #2499

Copy link
Contributor

github-actions bot commented Sep 11, 2025

Test Results

   546 files  ±0     546 suites  ±0   28m 55s ⏱️ - 4m 31s
 4 432 tests +1   4 415 ✅ +1   17 💤 ±0  0 ❌ ±0 
16 768 runs  +4  16 641 ✅ +4  127 💤 ±0  0 ❌ ±0 

Results for commit 6c2372b. ± Comparison against base commit 1094ebd.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare marked this pull request as ready for review September 11, 2025 15:53
@HeikoKlare HeikoKlare linked an issue Sep 11, 2025 that may be closed by this pull request
@fedejeanne
Copy link
Contributor

The test failure seems unrelated (it's in the Browser tests). Rebasing.

When calling GC#drawImage(), an operation is created (like for every
execution on GC) which stores the image to draw. Since the image may be
disposed afterwards, a dispose listener is registered to the image, such
that the image can be copied and maintained inside the operation in case
of a disposal until that operation itself is disposed.
The listener is currently not de-registered when disposing the GC and
its operations, thus the GC operations (and thus also the containing GC)
will still be referenced (as listeners from the image) until that image
is disposed. Since images may be long living (or never be disposed at
all), this can lead to a memory leak.

This change removes the listener from the image upon disposal of a GC
and its operations such that no memory can occur.

Fixes eclipse-platform#2499
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.

GC#drawImage can produce memory leak [Win32] GC#drawImage can produce memory leak
2 participants