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 Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BufferedImage OutOfMemoryError" Watch "BufferedImage OutOfMemoryError" New topic

BufferedImage OutOfMemoryError

andrea buegler

Joined: Mar 07, 2006
Posts: 2

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 = (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) {


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

Joined: Oct 29, 2001
Posts: 9070

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.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: BufferedImage OutOfMemoryError