I have this simple code here in my application:
public static boolean makeImage(String path){
BufferedImage inputImage = ImageIO.read(path);
}
I also tried this answer here but it doesn't matter how I initialize the BufferedImage, when the image is loaded in the BifferedImage, the RAM usage of the app goes up and never go down.
After the method is executed the ram is still occupied and when i call the method inputImage.flush()
nothing changes.
It does not seem to be a ImageIO.read(path)
problem cause initializing the image the other way has the same result.
How can i get rid of this BufferedImage from the RAM?
Edit: This line of code i reported here is the result of various tests in my application after isolating the memory increase to this buffered image. I am looking at the memory from task manager in windows and top command on linux. The memory does not grow until it throws OutOfMemoryException but remains stuck there as if the image is never released. This causes me problems because in my full application, various images are created over time and ram keeps growing. I looked at a heap dump and i see a large amount of byte[] elements but i am not sure how to interpret it because the dump i made when ram was low looks very similar to when i encountered the problem ( with over 1gb of ram occupied, normally is like 200 mb )