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
ImageIcon imageIcon = (ImageIcon) objectInputStream.readObject();
BufferedImage buffered = new BufferedImage(
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…