Community
Participate
Working Groups
Actually if gmfgraph Figure has Font or Color defined, generated code creates new instance of SWT Font/Color for each figure instantiation. This instance is never disposed, thus, creation of, say, 1000 colored figure instances will probably fail with "No More Handles" SWT exception. Even worse, the same exception may be reproduced with significatly less amount of figures just by reopening of the diagram. Expected: The org.eclipse.jface.resources.FontRegisry and org.eclipse.jface.resources.ColorRegistry may be used to dramatically reduce the number of blocked system resources. Alos these classes dispose resources at least on Display disposing. Thus, these classes should be used by generated Figure's code.
Created attachment 45186 [details] Fixes the subj
Created attachment 45304 [details] Fixes the subj (alternative way) Alternative version of the fix. Instead of generating Color- and Font- registry facade (see the first patch), this fix generates colors and fonts as public static final constants. In the standalone version of generator, these constants are added into the generated class body like normal static constants. In the InnerClassViewmap version, we can not add them into the figure code (because figure class is not static inner class and can not contain static members). So, with the help from small hack (see [oeg].graphdef.codegen/templates/top/classFooter.jetinc) we are generating the static constants _after_ the inner class body, that is as a constants in the enclosing class. NOTE: In contrast to registry-based solution, this approach DOES NOT dispose static colors and fonts anywhere. Though, the number of created instances is still limited to the number of different figure types. This change set DOES NOT obsolete the previous one -- any of solutions may be used.
Alternative patch reviewed, refactored and committed. Moving to next version as the issue requires thorough attention and risky changes to be done
Updated target milestone
there's no change compared with previous version, resources are allocated once but never disposed.
*** Bug 155983 has been marked as a duplicate of this bug. ***
Bulk update, target milestone 2.2
[GMF Restructure] Bug 319140 : product GMF and component Generation was the original product and component for this bug
Created attachment 183374 [details] Suggested patch for XPand templates This patch fixes the Figure template. Older patches are marked as obsolete since they were patching old JET templates.
(In reply to comment #9) > Created an attachment (id=183374) [details] Although ColorRegistry class is a nice latter addition to the Runtime, I don't think it makes a big difference - it is still static collection of colors (never disposed). Use of internal FontRegistry is not a good practice. At least, a bugzilla to make it part of API shall be filed, although such bug would only make the use legitimate, not any nicer. Appropriate solution would be disposable storage class generated/added to the runtime instead, with explicit cleanup (e.g. invoked once all diagram instances are closed) and/or weak/soft memory management.