Friday 12 July 2019

Java BufferedArrayOutputStream leaks in memory

I made a new question because this is different from my last thread. I now know what th e problem is more exact.



I create a new bytearrayoutputstream



ByteArrayOutputStream byteArray = new ByteArrayOutputStream();


Nothing special.

Then, when I write an image to it, this way



ImageIO.write(image, "gif", byteArray);


the memory increases like 100 mb first, not in eclipse, but in "reality". Then it slowly increases after that each time I write a new image to that stream OR another!!



and after a while it stops working and kinda crashes.



I have tried closing it and all that, flushing, reseting, everything, but it still leaks memory. I want it to get away from memory when I stop using byteArray or null it.




System.gc();


wont help in this case.



Please help me and anything else you need to know I will answer and please return and reply back :)

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...