Image caching in Java . How to clear memory?

983 views Asked by At

I'm developing a desktop java application. Each users have a panel showing personal information and also a profile image. The image is added through Swing JFileChooser, stored in a folder and its path saved in a local database as a string. Everything work, unless that the user have the possibility to change the image. Changing the image use a jFileChooser again, and is the same as adding the image from the beginning. The new path is stored correctly, but there's a cache memory issue. Problem is that images are stored in the hard drive with a file name that must be equal to the current user name. Changing image from the app will create a new image in that folder with the same name, overwriting the previous one. Now: - If i open the user panel again, the "old" image is shown, because new and old image path are identical and java use the cached image instead of reloading it - Closing the app and restarting it will solve the problem, so the path is stored correctly in the database and the issue must be related to the cache memory. Help me pls! Thanks in advance for your replies

0

There are 0 answers