Hi! On 3 Mai, 05:42, Alex Ghitza <aghi...@gmail.com> wrote: ... > I can see good reasons why we want the current behaviour of > "uniqueness of parents", and what we just saw here is a good reason > why we might *not* want it. How can we reconcile this? Can we make > it easy to turn off "uniqueness of parents" in some situations?
In a dirty way, certainly: The polynomial rings constructed with PolynomialRing are cached at sage.rings.polynomial.polynomial_ring_constructor._cache So, just delete appropriate items in that cache. Robert mentioned weak references. Does it mean the following? - When creating a reference to a polynomial ring in that cache, then tell the garbage collector that this reference should perhaps delay the deletion of the polynomial ring, but it should not prevent deletion. - When there is any other reference to the polynomial ring, then this counts as a proper reference, preventing the garbage collection. Hence, when you do sage: R=QQ['x'] then there is a weak reference in cache and a proper reference ``R`` to QQ['x']. So, the ring won't be garbage collected. When you continue sage: R=GF(3)['x'] then only the weak reference points to QQ['x']. So, the ring may be garbage collected. I think in this way one would have unique parents *and* would fix the memory leak, but I am afraid I don't know enough about weak references to implement it. Best regards, Simon --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---