Are there alternatives to using BufferedImage when creating images?

Are there alternatives to using BufferedImage when creating images?

Post by SteveBosma » Wed, 20 Oct 2004 17:47:03

As a part of a web app I am involved with I need to dynamically create
some large specialized graphs. These can be up to 6000 pixels wide and
2000 pixels deep. Using
BufferedImage image = new BufferedImage(6000, 2000,
BufferedImage.TYPE_INT_RGB);
requires 12Mb of memory which is unrealistic for one user to grab out
of the shared server memory and is leading to OutOfMemoryErrors.

Is there an alternative to using BufferedImage? In particular is there
anyway of using disk space as an image buffer prior to PNG encoding or
is this a completely insane idea?

BTW: The images compress to approximately 256Kb as PNG so passing them
to the browser is not too much of an issue.

TIA

Steve

 
 
 

Are there alternatives to using BufferedImage when creating images?

Post by Stefan Sch » Wed, 20 Oct 2004 18:14:24


Several possible solutions:

* Why bother with buffering the image? Since it appears not the be actively
displayed anyway, use an unbuffered image

* Since you are not displaying the image life, you can use disk space as
storage,
but beware: Access times will skyrocket, and you'll probably need to code
the disk interaction yourself.

* Do not worry about OOM until it proves to be the case. I never would have
said so a year ago, but OOM conditions arise much rarer then we'd usually
think. Don't worry about them until they actually arise. (If they already
arise, yes... then you should worry about them)



--

Whom the gods wish to destroy they first call promising.

 
 
 

Are there alternatives to using BufferedImage when creating images?

Post by Steve Bosm » Fri, 22 Oct 2004 17:24:16


actively
I thought PngEncoder in JFreechart required this, but looking at the
source it turns out that it doesn't.

as
code
This is what I want to do but I have no idea where to start. I guess I
was hoping someone had done something similar before and could
recommend a starting point or even better a file based Image class.