Two strange ideas:
- You can use a soft link to find out that you have little memory, and manually free some caches that themselves cannot use soft links.
- You can use the weak link to find out when the GC is running, which can be useful if you experience strange program pauses that may or may not be related to the GC.
IMHO, in some (rare) cases, weak links may be better for caching, for example, you can weakly refer to values ββthat are unlikely to be necessary again as soon as they are removed from structures using them (i.e. they become very unreachable) . Moreover, there is a serious bug in the JVM regarding soft links, which may make you do this.
source share