• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BufferedImage OutOfMemoryError

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic