• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BufferedImage OutOfMemoryError

 
andrea buegler
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic