From 2795ef570bd22ec14de45fca99ce10c89878b113 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sat, 22 Mar 2014 10:32:06 -0400 Subject: [PATCH] test for memory leak --- src/sage/symbolic/tests.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/sage/symbolic/tests.py diff --git a/src/sage/symbolic/tests.py b/src/sage/symbolic/tests.py new file mode 100644 index 00000000000..ae288b3d36c --- /dev/null +++ b/src/sage/symbolic/tests.py @@ -0,0 +1,38 @@ +""" +Tests for the Sage/Pynac interaction +""" + +#***************************************************************************** +# Copyright (C) 2013 Volker Braun +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + + +def rational_powers_memleak(): + """ + Check that there is no memory leak in rational powers + + See :trac:`9129`. + + EXAMPLES:: + + sage: from sage.symbolic.tests import rational_powers_memleak + sage: rational_powers_memleak() + False + """ + from sage.rings.all import ZZ + import gc + gc.collect() + c0 = sum(1 for obj in gc.get_objects()) + for i in range(1000): + a = ZZ(2).sqrt() + gc.collect() + c1 = sum(1 for obj in gc.get_objects()) + # Test that we do not leak an object at each iteration + return (c1 - c0) > 1000 +