[jbosstools-issues] [JBoss JIRA] (JBIDE-10245) org.jboss.tools.common.model.ui has 8 places with Image leaks

Viacheslav Kabanovich (Commented) (JIRA) jira-events at lists.jboss.org
Wed Nov 30 19:30:40 EST 2011


    [ https://issues.jboss.org/browse/JBIDE-10245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646954#comment-12646954 ] 

Viacheslav Kabanovich commented on JBIDE-10245:
-----------------------------------------------

Logic in LabelDecoratorImpl is not extra strange. This class creates by request for each available image two new images - one decorated with a small error mark, the other decorated with a small warning mark. To be reused, new images are bound to the original image by maps. Reuse makes sense, because original images are heavily reused. We could only do without maps by implementing an algorithm that creates the unique String key by Image object, as decorator has no access to original key by which the image was created; I think that map is a more simple solution.

I agree that we should register all created images in ImageRegistry so that they could be disposed by Eclipse when plugin is stopped. In case of images created in LabelDecoratorImpl, let it be unique random keys because we will continue to retrieve decorated images by maps.
                
> org.jboss.tools.common.model.ui has 8 places with Image leaks
> -------------------------------------------------------------
>
>                 Key: JBIDE-10245
>                 URL: https://issues.jboss.org/browse/JBIDE-10245
>             Project: Tools (JBoss Tools)
>          Issue Type: Sub-task
>          Components: common/jst/core
>    Affects Versions: 3.3.0.M4
>            Reporter: Vitali Yemialyanchyk
>            Assignee: Alexey Kazakov
>             Fix For: 3.3.0.Beta1
>
>
> XModelObjectAction line 145:
> {code}
> 		item.setImage(eclipseAction.getImageDescriptor().createImage());
> {code}
> LabelDecoratorImpl lines 53, 63:
> {code}
> 			i = d.createImage();
> {code}
> - here is extra strange logic and you use:
> {code}
> 	public static Image emptyImage = ModelUIImages.getImage("empty_co.gif"); //$NON-NLS-1$
> 	public static Image errorImage = ModelUIImages.getImage("error_co.gif"); //$NON-NLS-1$
> 	public static Image warningImage = ModelUIImages.getImage("warning_co.gif"); //$NON-NLS-1$
> 	List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
> 	static Map<Image,Image> errorImages = new HashMap<Image,Image>();
> 	static Map<Image,Image> warningImages = new HashMap<Image,Image>();
> {code}
> - which are never disposed.
> AbstractQueryDialog line 46:
> {code}
> 		setTitleImage(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT).createImage(null));
> {code}
> AbstractQueryWizardView line 153:
> {code}
> 			titleDialog.setTitleImage(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT).createImage(null));
> {code}
> DefaultSpecialWizardDialog line 56:
> {code}
> 		this.setTitleImage(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT).createImage(null));
> {code}
> ModelUIImages lines 58 & 98:
> {code}
> 	public static Image getImage(String key) {                   <------------------ create Image not get
> 		if(ModelUIPlugin.isDebugEnabled()) {
> 			ModelUIPlugin.getPluginLog().logInfo("Create image for key '"+key+"'."); //$NON-NLS-1$ //$NON-NLS-2$
> 		}
> 		return INSTANCE.createImageDescriptor(key).createImage();
> 	}
> ...
> 	public Image getImageByFileName(String key) {                 <------------------ create Image not get
> 		return createImageDescriptor(key).createImage();
> 	}
> {code}
> - is necessary to check all places where these methods call exist.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbosstools-issues mailing list