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

    Unhappy screen captured image@client save@Server BufferedImage OutOfMemoryError:JavaHeapSpace

    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 Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

Similar Threads

  1. Replies: 1
    Last Post: 01-27-2011, 08:08 AM
  2. Server socket - send image to client
    By Hinty in forum Networking
    Replies: 2
    Last Post: 03-14-2009, 07:39 AM
  3. Save a jpg image on server
    By yadavjpr in forum Java Servlet
    Replies: 1
    Last Post: 11-21-2008, 01:49 PM
  4. Replies: 0
    Last Post: 08-13-2008, 10:46 PM
  5. Replies: 13
    Last Post: 04-28-2008, 09:57 AM

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
  •