Results 1 to 2 of 2
  1. #1
    mame is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default new BufferedImage OutOfMemoryError: Java heap space

    I have client server program that the client send a screen captured image continuously to the server warping the BufferedImage to ImageIcon and then the client will read the ImageIcon and save it to a file via ImageIO.write using BufferedImage. Now the problem is for ever received image a new BufferedImage will be created in the while loop, after 6 fream there will be “OutOfMemoryError: Java heap space” error even if I increase the memory allocation for the project it wont work for more than 30 image.
    Any help is appreciated.

    Code snip where error occur
    While(true){
    ImageIcon imageIcon = (ImageIcon) objectInputStream.readObject();
    //……
    BufferedImage buffered = new BufferedImage(
    imageIcon.getIconWidth(),
    imageIcon.getIconHeight(),
    BufferedImage.TYPE_INT_RGB
    );
    //……
    }

    On each loop a new BufferedImage will be created and I don’t think the previous is freed from memory? So is there a manual freeing method like C++? Or just let it crash ever 6 frame…

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

Similar Threads

  1. Replies: 5
    Last Post: 08-13-2010, 11:04 AM
  2. java.lang.OutOfMemoryError: Java heap space
    By paul in forum Advanced Java
    Replies: 11
    Last Post: 06-12-2010, 06:30 PM
  3. OutOfMemoryError: Java heap space
    By redasu in forum New To Java
    Replies: 3
    Last Post: 04-23-2010, 01:05 PM
  4. Java heap space OutofMemoryError
    By everlast88az in forum Advanced Java
    Replies: 3
    Last Post: 05-18-2009, 09:12 AM
  5. [SOLVED] Java heap space OutOfMemoryError
    By loki in forum New To Java
    Replies: 14
    Last Post: 04-25-2009, 05:11 PM

Tags for this Thread

Posting Permissions

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