I have been thinking of ways to improve my image cache.
Currently I a WeakHashMap which maps an ID to an image.
If the ID isn’t in the map it will load that image and then save it to the map.
The problem is that multiples of the same images will be stored in memory.
Say its loading images from an unknown source, and so can’t improve it before this.
I’m trying to figure out a way to check after loading the image that if the same image is already in the image cache and use that instead. I guess a way would have 2 WeakHashMaps, one to map which does the id to the image and the other to do the imageID to the image.
I guess my problem is what would be the best way to get an image ID which is always the same for the same image.