leif wrote:
> Nathann Cohen wrote:
>> It is not deallocated when you quit Sage either. This is how I noticed it.
>
> So we'd in principle have to revert the changes made by #13741.
>
> Using 'del pari' in quit_sage() doesn't work, and one cannot call
> pari.__dealloc__() explicitly, hence another function has to be added
> back which does the clean-up (to be called from quit_sage()).
This works for me (quick'n'dirty):
diff --git a/src/sage/all.py b/src/sage/all.py
index d2494e0..0ee1d04 100644
--- a/src/sage/all.py
+++ b/src/sage/all.py
@@ -258,6 +258,10 @@ def quit_sage(verbose=True):
from sage.libs.all import symmetrica
symmetrica.end()
+ # del sage.libs.pari.pari_instance.pari won't work
+ pari._clean_up()
+
+
from sage.ext.interactive_constructors_c import inject_on, inject_off
sage.structure.sage_object.register_unpickle_override('sage.categories.category', 'Sets', Sets)
diff --git a/src/sage/libs/pari/pari_instance.pyx
b/src/sage/libs/pari/pari_instance.pyx
index 5f91c01..a2e59fe 100644
--- a/src/sage/libs/pari/pari_instance.pyx
+++ b/src/sage/libs/pari/pari_instance.pyx
@@ -495,6 +495,9 @@ cdef class PariInstance(PariInstance_auto):
indirect doctest. See the discussion at :trac:`13741`.
"""
+ self._clean_up()
+
+ def _clean_up(self):
sage_free(<void*>pari_mainstack.vbot)
pari_mainstack.rsize = 0
pari_mainstack.vsize = 0
Haven't tested with valgrind though.
-leif