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?

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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

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

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

AFAIK, set color only accepts a Color type object....

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

You might have ment fillRect...

Did that too and nothing.

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

sorry its fillRect..
pardon me ...

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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!

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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

Hello is shown on the screen. Bye isnt.

The bufferimage is the problem right?

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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

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

....what?

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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.

Re: Small BufferedImage = java.lang.OutOfMemoryError: Java heap space ??? 80 80

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....)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.