diff --git a/src/sage/repl/ipython_kernel/interact.py b/src/sage/repl/ipython_kernel/interact.py index a0097cd48f7..ddc16dd79dc 100644 --- a/src/sage/repl/ipython_kernel/interact.py +++ b/src/sage/repl/ipython_kernel/interact.py @@ -131,7 +131,16 @@ def __repr__(self): for w in widgets: s += "\n %s: %s" % (w._kwarg, w) return s - + def update(self, *args, **kwargs): + """ + Override update to force garbage collection after each call. + """ + import gc + try: + super().update(*args, **kwargs) + finally: + gc.collect() + def signature(self): """ Return the fixed signature of the interactive function (after