0

Hey

Putting this code:

System.out.println("Hello");
BufferedImage bufferedImage = new BufferedImage(620, 420, BufferedImage.TYPE_INT_RGB);
System.out.println("Bye");
		Graphics2D g2d = bufferedImage.createGraphics();
		g2d.setColor(Color.black);
		g2d.fillRect(0, 0, 620,420);  
		g2d.setColor(Color.yellow);

It throws a java.lang.OutOfMemoryError: Java heap space error not displaying the bye. I dont understand as my BufferedImage is nothing at all (simple 620 by 420).

Why is this happening?

3
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by riahc3
0

reduce the setColor values to (0,0,619,419).

Image may overlapse as the size are identical hence ot of bounds error. try that!

0

Seems very unlikely that that code fragment, on its own, would run out of heap (unless you're using JavaME?). Maybe it's something in the rest of your code - can you post it all - if it's big a small runnable demo of the part that fails would be even better!

0

But other code there has nothing to do with this...

Hello is shown on the screen. Bye isnt.

The bufferimage is the problem right?

0

.....remove the bufferimage refrence to test something and now:

java.net.BindException: Address already in use: JVM_Bind

....what?

0

OK - run out of memory, then trying to execute a bind that has already been executed.
My best guess is that either you are in a simple infinite loop, or you are making a recursive call without a proper termination condition. I assume that would not be deliberate. Trace the execution with a few well-placed print statements.

0

OK - run out of memory, then trying to execute a bind that has already been executed.
My best guess is that either you are in a simple infinite loop, or you are making a recursive call without a proper termination condition. I assume that would not be deliberate. Trace the execution with a few well-placed print statements.

Restarted Windows and everything is fixed (" ": New thread coming up....)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.