Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Resource Leak CSSSWTFontHelper, CSSSWTColorHelper(Resources not managed by CSS-Engine)
icon4.gif  Resource Leak CSSSWTFontHelper, CSSSWTColorHelper [message #1618891] Mon, 16 February 2015 07:39 Go to next message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
Hello,

I detected (with Sleak) a resource problem in the CSS Engine.
CSSSWTFontHelper.getFont(CSS2FontProperties fontProperties,
			FontData oldFontData, Display display)

A new font gets created, but not shared or disposed again. Similar is the situation here:
CSSSWTColorHelper.getSWTColor(CSSValue value, Display display)


For each control of the same instance the font is created again and consumes resources of the OS. I expected that the CSS-Engine uses a resource manager or a registry (ColorRegistry, FontRegistry) to handle the resources of SWT.

Is there anything I have to notice when using the CSS Engine? Is there a way to handle this problem? Resource leaks are a big problem in this case.

Edit: I uploaded a plugin with 2 themes, which shows the problem. Starting the product also starts Sleak. When switching between the 2 themes, you will see that the CSSEngine alsways creates new Fonts and does not release them again.

[Updated on: Mon, 16 February 2015 08:38]

Report message to a moderator

Re: Resource Leak CSSSWTFontHelper, CSSSWTColorHelper [message #1619026 is a reply to message #1618891] Mon, 16 February 2015 09:32 Go to previous messageGo to next message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
I think, I have found the problem in CSSResourceHelpers:
	public static String getCSSFontPropertiesKey(
			CSS2FontProperties fontProperties) {
		return fontProperties.getFamily() + "_" + fontProperties.getSize()
				+ "_" + fontProperties.getStyle() + "_"
				+ fontProperties.getWeight();
	}

The key of the font gets returned by connecting the single properties of the font with '_'. But the single properties are instances of org.eclipse.e4.ui.css.core.impl.dom.Measure. So you receive a key like:
"org.eclipse.e4.ui.css.core.impl.dom.Measure@444fe1_org.eclipse.e4.ui.css.core.impl.dom.Measure@d859a3_org.eclipse.e4.ui.css.core.impl.dom.Measure@138d0ab_org.eclipse.e4.ui.css.core.impl.dom.Measure@1e4e2eb"

This should be more like:
fontProperties.getFamily().getCssText() + "_" + fontProperties.getSize().getCssText() + "_" + fontProperties.getStyle().getCssText() + "_"	+ fontProperties.getWeight().getCssText()

It seems that this bug cannot be solved without patching org.eclipse.e4.ui.css.core
Re: Resource Leak CSSSWTFontHelper, CSSSWTColorHelper [message #1620320 is a reply to message #1619026] Tue, 17 February 2015 05:33 Go to previous message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
Eclipse Bug opened:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=459983
Previous Topic:Life cycle hook is not called (anymore!)
Next Topic:Custom window heading
Goto Forum:
  


Current Time: Thu Apr 25 14:55:59 GMT 2024

Powered by FUDForum. Page generated in 0.04271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top