Commit 07c2347
[Win32] Fix potential memory leak in GC#drawImage eclipse-platform#2499
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#24991 parent 8c237c5 commit 07c2347
File tree
3 files changed
+36
-1
lines changed- bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics
- tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit
3 files changed
+36
-1
lines changedLines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
494 | 495 | | |
495 | 496 | | |
496 | 497 | | |
| 498 | + | |
| 499 | + | |
497 | 500 | | |
498 | 501 | | |
499 | | - | |
| 502 | + | |
500 | 503 | | |
501 | 504 | | |
502 | 505 | | |
| |||
515 | 518 | | |
516 | 519 | | |
517 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
518 | 526 | | |
519 | 527 | | |
520 | 528 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1023 | 1030 | | |
1024 | 1031 | | |
1025 | 1032 | | |
1026 | 1033 | | |
| 1034 | + | |
1027 | 1035 | | |
1028 | 1036 | | |
1029 | 1037 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
807 | 826 | | |
808 | 827 | | |
809 | 828 | | |
| |||
0 commit comments