On Wednesday, December 5, 2018 at 1:53:07 PM UTC-8, Jeroen Demeyer wrote:
>
>
> With my idea, the domain and codomain would be treated exactly the same: 
> my plan is to reference the map from both the domain and codomain in a 
> symmetric way. In that way, the lifetime of A wouldn't depend on C the 
> same way that the lifetime of B or C doesn't depend on A.
>

Then you DO get a memory leak as soom as UniqueRepresentation objects are 
involved. Let's assume that B is constructed from A. Then a strong 
reference to A exists because A occurs as a key in the UniqueRepresentation 
weakvalue dict. Because the coercion map from A to B is also stored on A, a 
strong reference to B exists. As long as A and B are alive, the coercion 
map is alive as well, so these references don't change.

A really has its life time lower bounded by B. So somehow, you'd want B to 
be collectible under some circumstances. But then the coercion map needs to 
be "unreachable" as well, because it carries a strong reference to B.

Conversely, as long as B is alive, A is also alive, so the coercion map 
must be reachable. So it seems to me B should just have a strong reference 
to the coercion map. Furthermore, A should not have a strong reference to 
the coercion map, because otherwise A and B are immortal.

It doesn't look to me as if a MultiWeakRef is going to help at all with the 
lifetime problems here.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to