<Swing Dev> Review Request for 8163261: regression on Linux: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java

Alexander Scherbatiy alexandr.scherbatiy at oracle.com
Mon Aug 22 12:16:54 UTC 2016


On 17/08/16 15:49, Alexandr Scherbatiy wrote:
> On 8/15/2016 12:43 PM, Ambarish Rapte wrote:
>>
>> Hi,
>>
>>                 Please review fix for JDK9,
>>
>>                 Bug: https://bugs.openjdk.java.net/browse/JDK-8163261
>>
>>                 Webrev: 
>> http://cr.openjdk.java.net/~arapte/8163261/webrev.00/ 
>> <http://cr.openjdk.java.net/%7Earapte/8163261/webrev.00/>
>>
>> Issue:
>>
>>                 Reference to JButton was not getting collected by GC.
>>
>> Cause:
>>
>>                 A strong reference to objects was held by 
>> PainterMultiResolutionCachedImage.
>>
>>                 And the image reference was held by HashMap.
>>
>> Fix:
>>
>>                 Changing the HashMap to WeakHashMap. Entry to 
>> WeakHashMap gets removed after the object has no other strong reference.
>>
>     May be using the soft reference would be better in this case. It 
> could be expensive to recreate a cache with images every time GC 
> removed them.

There is the code which sets a component to the 
PainterMultiResolutionCachedImage:
CachedPainter.paint0(...)
-------
         if (image instanceof PainterMultiResolutionCachedImage) {
             ((PainterMultiResolutionCachedImage) image).setParams(c, args);
         }

         // Render to the passed in Graphics
         paintImage(c, g, x, y, w, h, image, args);
-------

May be it is possible to clean up the component and args from the 
PainterMultiResolutionCachedImage after the image is drawn?

>
>   Thanks,
>   Alexandr.
>>
>> Regards,
>>
>> Ambarish
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20160822/a7aa791b/attachment.html>


More information about the swing-dev mailing list