But they are. Java has a gargabe collector that knows way more than the OS does and can optimize for when to call it. Then the two objects you use are WeakReference and SoftReference, Weak is used to tell the GC to clear as soon as no one else is using this object and Soft indicates that the GC should leave the object in memory and only clear on memory contention.

Replies (2)

These are all theoretical without much substance to back it up. The real benefits is not just automatic memory management, it’s the not needing the in memory cache at all. no async code and things being out of sync : View quoted note →
They are not theorical man... Efficient garbage collection without the dev even thinking about it is literally the whole reason Java exists. Every app uses those things all the time. For many apps, the cache is just the list objects for the feed itself. We do some crazy things on top of it, but I don't expect anyone to have to do it for smaller apps. The rest is just regular loads using Nostr filters.