Commit 3007c05
committed
Fix memory-leak in FigureUtilities by disposing GC on font change
Before this change figureUtilities created a GC once for an application and then reused it to calculate font/text dimensions. Due to the recent modification of GC in SWT to store Operations, every operation on FigureUtilities that sets the font on the GC (i.e., that calls setFont()) creates a SetFontOperation in the GC. Since that GC is never disposed, these operation accumulate throughout the application lifecycle and constituted a memory leak
The current change addresses this issue by instead of crearting a single GC we create a single shell for the lifetime of the application. Whenever a different font needs to be set, the old GC is properly disposed and replaced with a new one created from the shell. This ensures that no GC objects persist indefinitely, effectively preventing the memory leak. The now-unused getGC() method which was protected has been removed from the codebase as part of this change.1 parent 8726ed7 commit 3007c05
File tree
1 file changed
+14
-19
lines changed- org.eclipse.draw2d/src/org/eclipse/draw2d
1 file changed
+14
-19
lines changedLines changed: 14 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
78 | 71 | | |
79 | 72 | | |
80 | 73 | | |
81 | | - | |
82 | | - | |
83 | 74 | | |
84 | | - | |
| 75 | + | |
85 | 76 | | |
86 | 77 | | |
87 | 78 | | |
| |||
95 | 86 | | |
96 | 87 | | |
97 | 88 | | |
98 | | - | |
| 89 | + | |
99 | 90 | | |
100 | 91 | | |
101 | 92 | | |
| |||
123 | 114 | | |
124 | 115 | | |
125 | 116 | | |
126 | | - | |
| 117 | + | |
127 | 118 | | |
128 | 119 | | |
129 | 120 | | |
| |||
341 | 332 | | |
342 | 333 | | |
343 | 334 | | |
344 | | - | |
| 335 | + | |
345 | 336 | | |
346 | 337 | | |
347 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
348 | 343 | | |
349 | 344 | | |
350 | 345 | | |
| |||
0 commit comments