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?




For the folks following this thread, Rob brought up a good question. He suggested that I verify that I was, in fact, receiving the BufferedImage instances that I thought I was getting. In my first reply to Rob (see below), I provided information that was present in the documentation for the library that was generating the Images. That documentation indicated that "createCompatibleImage()" was being used to generate BufferedImage objects (don't worry -- this is not an Apple or Sun developed library).


Apparently, the library documentation has not been updated, because when I check the type of the returned objects in the debugger, I find that I am receiving "apple.awt.OSXImage" instances, not the BufferedImage instances I expected. I then wrote a little test program, and I found that "apple.awt.OSXImage" instances are returned by the java.awt.Toolkit.createImage() method.

So, perhaps we have an explanation here. I've found that flush()ing my images made a big difference in my program's ability to reclaim memory, but, as we thought we were using BufferedImages, we were unable to determine why this action would matter for that particular java.awt.Image variant. In fact, it would seem that this library method I am using is not returning the promised BufferedImage, but instead a different Image subclass. Hence, the flush() method is useful for the actual instance returned.

I suppose the lesson learned here is that if you only know you're going to acquire some generic java.awt.Image subclass, go ahead and make arrangements to flush() it.

Regards,
-Mike Ellis


On Mar 29, 2006, at 11:21 AM, Michael Ellis wrote:


On Mar 29, 2006, at 11:13 AM, Rob Cope wrote:


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


Hi Rob.

This is an excellent question, indeed. It is definitely worth mentioning that I am using the "createCompatibleImage()" method of the Component's top-level container (JFrame) to create the BufferedImage instances.

If I get a second later on, I'll determine exactly which Class is being returned by that method.

Regards,
-Mike Ellis

=========================
Michael F. Ellis
President
Ellis Softworks Inc.
----------
Phone:  (941) 713-0361
Email: email@hidden
Web: http://www.ellissoftworks.com



========================= Michael F. Ellis President Ellis Softworks Inc. ---------- Phone: (941) 713-0361 Email: email@hidden Web: http://www.ellissoftworks.com


_______________________________________________ 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>)
 >Re: BufferedImages not garbage collected -- any suggestions? (From: Rob Cope <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.