✅ Difference Between WeakReference and SoftReference
| Feature | WeakReference | SoftReference |
|---|---|---|
| GC behavior | Collected as soon as no strong refs | Collected only when memory is low |
| Lifespan | Short | Longer (survives longer in memory) |
| Use case | Automatic cleanup | Memory-sensitive cache |
So in theory:
Continue reading✅
WeakHashMap→ removes entries aggressively
✅SoftHashMap→ removes entries only if memory is tight → perfect for caching