aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes BufferedImage OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BufferedImage OutOfMemoryError" Watch "BufferedImage OutOfMemoryError" New topic
Author

BufferedImage OutOfMemoryError

andrea buegler
Greenhorn

Joined: Mar 07, 2006
Posts: 2
Hello,

i have to create a BufferedImage - Object.
i must create different Objects like graphic objects,
but although Objects like Buttons Comoboboxes and so on...

in the code paintComponent exist

...bi = (BufferedImage) createImage(3060, 6188);

The Image could have the size 3060 and 6188.

--> if the size is 3060, 6188 i get an OutOfMemoryError.

I don't want maximize the heap size with -Xmx200m

public void paintComponent(Graphics g) {

super.paintComponent(g);

Graphics2D g2 = (Graphics2D) g;
Dimension dim = getSize();
int w = dim.width, h = dim.height;

// UPDATE SO: !! update code - bi=BufferedImage

if (bi == null) {
bi = (BufferedImage) createImage(w, h);
big = bi.createGraphics();
area = new Rectangle(dim);
end if;
...

}

any idea?

Hope somebody could help me
Thank you!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

The default VM heap is 64 megabytes. An image 3060x6188 can occupy over 144 megs (depending on color depth and resolution). You have to increase the heap size with the command-line switch.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: BufferedImage OutOfMemoryError