Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 129466

Summary: PrinterGraphics does not dispose imageCache
Product: [Tools] GEF Reporter: Marcos César de Oliveira <mcesar>
Component: GEF-Legacy Draw2dAssignee: Steven R. Shaw <steveshaw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1    
Version: 3.1.1   
Target Milestone: 3.2.0 (Callisto) M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Marcos César de Oliveira CLA 2006-02-25 17:45:54 EST
PrinterGraphics maintains an cache of resized images in the imageCache field, but neither disposes the images created nor allows them to be disposed, resulting in the leak of the images.

This is the code I have used to do the disposition of the images:

        Map imageCache = null;
        try {
            Field field = PrinterGraphics.class.getDeclaredField("imageCache");
            field.setAccessible(true);
            imageCache = (Map) field.get(graphics);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (imageCache != null) {
            for (Image image : (Collection<Image>) imageCache.values()) {
                image.dispose();
            }
        }
Comment 1 Randy Hudson CLA 2006-02-26 18:04:33 EST
Puxa vida... This will get fixed for 3.2.
Comment 2 Steven R. Shaw CLA 2006-03-08 14:44:14 EST
added dispose method to PrinterGraphics.