This is actually SoftRef - which are like a WeakRef but they are only collected under memory pressure.
If the WeakRef package works, I assume it could be modified to enable “soft ref” like functionality. It was my understanding that you need GC/runtime support to truly make this work, but maybe they have an Unsafe/CGO way. I haven’t really researched the WeakRef packages for Go. > On Jan 20, 2020, at 4:58 PM, Eric S. Raymond <e...@thyrsus.com> wrote: > > Robert Engels <reng...@ix.netcom.com>: >> This is solved pretty easily in Java using soft references and a hard memory >> cap. > > That'd be nice, but the onnly weak-references package I've found doesn't seem > to allow > more than one weakref per target. That's really annoying, because my use case > is > a target object for a many-to-one mapping that should become GCable when the > last of its source objects is GCed. > > Is there a weakrefs implementation out tere that will do that? > -- > <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/20200120225853.GA75815%40thyrsus.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/A97065E1-66FD-42A5-9E6B-7AFA5CD96A68%40ix.netcom.com.