Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BufferedImages not garbage collected -- any suggestions?



Michael Ellis wrote:


This memory leak search began when I was qualifying code that scrolls through thousands of BufferedImages. Of course, only a small fraction of these images are displayed at any given time, so the code has occasion to create new BufferedImages for the ones being displayed and to dispose of the unused, out-of-view instances. I think that it is worth mentioning that each BufferedImage is owned by a Component that is responsible for painting the image.

[snip]

What made the difference was having the Component class' "finalize()" method explicitly call "flush()" on its BufferedImage before nulling it out. Once this was done, the verbose output from the GC confirmed that the BufferedImage's memory was being reclaimed and the OutOfMemoryException stopped.


Given what others have observed about BufferedImage.flush(), I'm wondering how you are creating your BufferedImages. If you are having the component create it, or calling createCompatibleImage(), then maybe you are getting a subclass of BufferedImage that does something different? Sorry, I haven't got time to test that right now, but it would interesting to know.

Rob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: BufferedImages not garbage collected -- any suggestions? (From: Michael Ellis <email@hidden>)
 >Re: BufferedImages not garbage collected -- any suggestions? (From: Michael Hall <email@hidden>)
 >Re: BufferedImages not garbage collected -- any suggestions? (From: Michael Ellis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.