There is a WeakHashMap instance initialized with, for example, 500 entries. Now, its keys have not been referenced anywhere in the running application for a day or so. Will this map's entries be removed automatically after a certain time gets passed?
My understanding is that if key is not referenced then corresponding entries will be removed from the map.
It will be removed when GC runs if your key is not referenced anywhere: (Reference)
The removal time is unknown:
But be careful, some object like boxed Integer of small integers like -127-> 127 are cached by JVM so if you use autoboxed Integer key, it will never be removed from the Map.