[JBoss JIRA] (JBIDE-10229) org.jboss.tools.jst.css.dialog.ImageSelectionDialog has GC leaks logik
by Vitali Yemialyanchyk (Created) (JIRA)
org.jboss.tools.jst.css.dialog.ImageSelectionDialog has GC leaks logik
----------------------------------------------------------------------
Key: JBIDE-10229
URL: https://issues.jboss.org/browse/JBIDE-10229
Project: Tools (JBoss Tools)
Issue Type: Sub-task
Components: common/jst/core
Affects Versions: 3.3.0.M4
Reporter: Vitali Yemialyanchyk
Assignee: Alexey Kazakov
{code}
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = new GC(canvas); <-------------------------- here you create GC
gc.setForeground(emptyColor);
gc.fillRectangle(1, 1, canvas.getSize().x - 2, canvas.getSize().y - 2);
// resolution.setText("");
resolution.setVisible(false);
if (file != null) { <-------------------------- here you check condition
Cursor parentCursor = getShell().getCursor();
final Cursor waitCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT);
Point previewPoint = new Point(0, 0);
Point labelPoint = canvas.getSize();
InputStream stream = null;
try {
getShell().setCursor(waitCursor);
stream = new FileInputStream(file.getLocation().toOSString());
ImageData imageData = new ImageData(stream);
stream.close();
if (imageData != null) {
Image image = new Image(getShell().getDisplay(), imageData);
// set image in center
Point imagePoint = new Point(image.getBounds().width,
image.getBounds().height);
String imageInfo = imagePoint.x + " x " + imagePoint.y + " px"; //$NON-NLS-1$ //$NON-NLS-2$
// change resolution if image anymore image label
if ((imagePoint.x > labelPoint.x) || (imagePoint.y > labelPoint.y)) {
float ratioImage = (float) imagePoint.x / (float) imagePoint.y;
if (((imagePoint.y > labelPoint.y) &&
((labelPoint.y * ratioImage) > labelPoint.x)) ||
((imagePoint.x > labelPoint.x) &&
((labelPoint.x / ratioImage) < labelPoint.y))) {
imageData = imageData.scaledTo(labelPoint.x - 10,
(int) (labelPoint.x / ratioImage));
} else {
imageData = imageData.scaledTo((int) (labelPoint.y * ratioImage) -
10, labelPoint.y);
}
image.dispose();
image = new Image(getShell().getDisplay(), imageData);
imagePoint.x = image.getBounds().width;
imagePoint.y = image.getBounds().height;
}
previewPoint.x = (labelPoint.x / 2) - (imagePoint.x / 2);
previewPoint.y = (labelPoint.y / 2) - (imagePoint.y / 2);
gc.drawImage(image, previewPoint.x, previewPoint.y);
resolution.setVisible(true);
resolution.setText(imageInfo);
image.dispose();
gc.dispose(); <-------------------------- here you dispose
}
} catch (IOException ev) {
//ignore
} catch (SWTException ex) {
//ignore (if select not image file)
} finally {
getShell().setCursor(parentCursor);
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
// ignore
}
}
}
}
}
});
{code}
here is absolutely invalid logic, guys :)
you close the stream in two places - try to find: stream.close();
I've check a history of changes:
>>>
PMD violations fixed.
InputStreams close() added where it was possible.
>>>
8/29/08 - someone try to close all streams where it possible, after that all of you respect his authority and afraid to fix his error...
btw., you are still has a problems with "close of all streams", after 8/29/08 changes...
--
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
14 years, 4 months
[JBoss JIRA] (JBIDE-10245) org.jboss.tools.common.model.ui has 8 places with Image leaks
by Vitali Yemialyanchyk (Created) (JIRA)
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
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
14 years, 4 months
[JBoss JIRA] (JBIDE-10248) org.jboss.tools.jst.web.kb creates but never dispose images
by Vitali Yemialyanchyk (Created) (JIRA)
org.jboss.tools.jst.web.kb creates but never dispose images
-----------------------------------------------------------
Key: JBIDE-10248
URL: https://issues.jboss.org/browse/JBIDE-10248
Project: Tools (JBoss Tools)
Issue Type: Sub-task
Components: common/jst/core
Affects Versions: 3.3.0.M4
Reporter: Vitali Yemialyanchyk
Assignee: Alexey Kazakov
Priority: Minor
in these classes: ActionProposalType, ConverterIDProposalType, ConverterIDProposalType, EnumerationProposalType, FacetNameProposalType, IDProposalType, ResourceBundleNameProposalType, ResourcePathProposalType you initialize
{code}
private static Image ICON;
{code}
field with new image, but never dispose it.
imo may be a better to put these images in org.jboss.tools.jst.web.kb plugin image registry, so you can avoid image leak after plugin org.jboss.tools.jst.web.kb stop it's work.
--
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
14 years, 4 months
[JBoss JIRA] (JBIDE-10222) VpeController has resource leaks
by Vitali Yemialyanchyk (Created) (JIRA)
VpeController has resource leaks
--------------------------------
Key: JBIDE-10222
URL: https://issues.jboss.org/browse/JBIDE-10222
Project: Tools (JBoss Tools)
Issue Type: Sub-task
Components: Visual Page Editor core
Affects Versions: 3.3.0.M4
Reporter: Vitali Yemialyanchyk
Assignee: Yahor Radtsevich
line 1664:
{code}
Color bckgColor = new Color(tip.getDisplay(), 255, 250, 236);
{code}
line 1701:
{code}
Color color = new Color(tipControlHeaderText.getDisplay(), 201,
51, 40);
{code}
line 1747:
{code}
Color color = new Color(tipControlHeaderText
.getDisplay(), 42, 148, 0);
{code}
VpeDropWindow has in line 52:
{code}
static final Color BACKGROUND_COLOR = new Color(null, 0xff, 0xff, 0xcd);
{code}
- generally is not a leak here, but a better way to store RGB value and create color and dispose it
--
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
14 years, 4 months