Friday, July 12, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...