Skip to main content

ImageIO.setUseCache(false)

2 replies [Last post]
davidthi808
Offline
Joined: 2005-11-03

Hi;

We are finding on AIX systems that setting ImageIO.setUseCache(false) leads to a 10-fold improvement in our calls to:
ImageInputStream imageInput = ImageIO.createImageInputStream(new ByteArrayInputStream(image));

Any idea if this makes any sense? Or is this just some kind of timing bug in AIX?

thanks - dave

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Simone Giannecchini

Setting ImageIO.setUseCache to false forces imageio to use
MemoryCacheImageInputStream on subsequent calls to
ImageIO.createImageInputStream(new ByteArrayInputStream(image)) which
is optimal in your case. In general whenever you have data already in
memory is good to use directly MemoryCacheImageInputStream over
FileCacheImageInputStream, providing that you have enough memory
availaible!!!

If you use FileCacheImageInputStream you would hardly run into
OutOfMemoryError because the data is cached on dsk instead of in
memory but performances will degrade.

Simone.

On 12/5/06, jai-imageio@javadesktop.org wrote:
> Hi;
>
> We are finding on AIX systems that setting ImageIO.setUseCache(false) leads to a 10-fold improvement in our calls to:
> ImageInputStream imageInput = ImageIO.createImageInputStream(new ByteArrayInputStream(image));
>
> Any idea if this makes any sense? Or is this just some kind of timing bug in AIX?
>
> thanks - dave
> [Message sent by forum member 'davidthi808' (davidthi808)]
>
> http://forums.java.net/jive/thread.jspa?messageID=182826
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

davidthi808
Offline
Joined: 2005-11-03

Hi;

Ok, I'll buy that it is faster not using it as we have it in memory already. But...

1) Isn't the code smart enough to realize it's in a byte array and therefore it can re-read any data?

2) Does it make sense that having the cache set to true makes it 10 times slower - we get that level of degradation only on AIX systems - and only on some.

Finally, if I call this once at startup, it will stay flase for as long as the JVM is running for all of my code - correct? Or do I need to call it for each thread?

thanks - dave