1 | | (Moving this to "coercion", which is clearly where it belongs.) |

| 1 | Here is a small example illustrating the issue. |

| 2 | |

| 3 | The memory footprint of the following piece of code grows indefinitely. |

| 4 | |

| 5 | {{{ |

| 6 | sage: K = GF(1<<55,'t') |

| 7 | sage: a = K.random_element() |

| 8 | sage: while 1: |

| 9 | ....: E = EllipticCurve(j=a); P = E.random_point(); 2*P; del E, P; |

| 10 | |

| 11 | }}} |

| 12 | E and P get deleted, but when 2*P is computed, the action of integers on A, the abelian group of rational points of the ellitpic curve, gets cached in the corecion model. |

| 13 | |

| 14 | A key-value pair is left in coercion_model._action_maps dict: |

| 15 | |

| 16 | (ZZ,A,*) : IntegerMulAction |

| 17 | |

| 18 | Moreover there is at least also references to A in the IntegerMulAction and one in ZZ._action_hash. |

| 19 | |

| 20 | So weak refs should be used in all these places if it does not slow things too much. |