Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
test for memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
vbraun committed Mar 22, 2014
1 parent f4fdcea commit 2795ef5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/sage/symbolic/tests.py
@@ -0,0 +1,38 @@
"""
Tests for the Sage/Pynac interaction
"""

#*****************************************************************************
# Copyright (C) 2013 Volker Braun <vbraun.name@gmail.com>
#
# 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

0 comments on commit 2795ef5

Please sign in to comment.