Results 1 to 4 of 4
  1. #1
    MrFish is offline Member
    Join Date
    Jan 2010
    Posts
    43
    Rep Power
    0

    Default OutOfMemoryError

    Why does this create an out of memory error?

    Java Code:
    public void setImageToColor()
    	{
    		image = new BufferedImage(250, 250, BufferedImage.TYPE_INT_RGB);
    		Graphics2D g = (Graphics2D)image.getGraphics();
    		g.setBackground(color);
    	}
    I don't know if it has anything to do with it. But image is not a BufferedImage, it is an Image.

  2. #2
    funnyboy's Avatar
    funnyboy is offline Member
    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0

    Default

    I don't know much about this, but maybe if you add an argument to the method? I'm thinking of the Graphics g

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by MrFish View Post
    Why does this create an out of memory error?
    It doesn't. Your problem lies elsewhere in code not shown here. Perhaps you're calling this method recursively? We won't know though until you give us more information.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by MrFish View Post
    I don't know if it has anything to do with it. But image is not a BufferedImage, it is an Image.
    Also, the image variable may be an Image type, but it references a BufferedImage object, so it in fact is a BufferedImage.

Similar Threads

  1. Java heap space OutofMemoryError
    By everlast88az in forum Advanced Java
    Replies: 3
    Last Post: 05-18-2009, 09:12 AM
  2. OutOfMemoryError
    By bj2me in forum CLDC and MIDP
    Replies: 3
    Last Post: 02-10-2009, 01:22 PM
  3. java.lang.OutOfMemoryError
    By new_2_java in forum New To Java
    Replies: 2
    Last Post: 11-01-2008, 06:12 AM
  4. java.lang.OutOfMemoryError
    By vidhya.sk in forum New To Java
    Replies: 2
    Last Post: 09-18-2008, 01:21 PM
  5. OutOfMemoryError
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 11-11-2007, 08:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •