Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak --- Polynomial arithmetic over finite field #274

Closed
sagetrac-ifti mannequin opened this issue Feb 21, 2007 · 6 comments
Closed

memory leak --- Polynomial arithmetic over finite field #274

sagetrac-ifti mannequin opened this issue Feb 21, 2007 · 6 comments

Comments

@sagetrac-ifti
Copy link
Mannequin

sagetrac-ifti mannequin commented Feb 21, 2007

Leaks like a bad ...


sage: get_memory_usage()
'276M'
sage: K = GF(10007^2, 'a')
sage: X = PolynomialRing(K, 'x').gen()
sage: for i in range(1000):
    s = K.random_element(); t = K.random_element()
    poly = s + t*X
....:     
sage: get_memory_usage()
'281M'

Component: number theory

Issue created by migration from https://trac.sagemath.org/ticket/274

@williamstein
Copy link
Contributor

comment:1

This much simpler example also leaks:

sage: K = GF(10007^2, 'a')
sage: X = PolynomialRing(K, 'x').gen()
sage: s = K.random_element(); t = K.random_element()
sage: for i in range(1000):
    _ = t*X

@williamstein
Copy link
Contributor

comment:2
09:10 < was_> the problem is also *only* over GF(10007^2)
09:10 < was_> not over GF(10007)
09:10 < was_> so it's givaro, probably.

@williamstein
Copy link
Contributor

comment:3

Not givaro, pari:

sage: K = GF(10007^2, 'a')
sage: type(K)
<class 'sage.rings.finite_field.FiniteField_ext_pari'>

@williamstein
Copy link
Contributor

comment:4

The problem is in polynomial creation.

K = GF(2^16, 'a')
print type(K)
R.<x> = K[]
print type(R)
s = K.random_element()

def leak(n):
    m = get_memory_usage()
    for i in range(n):
        _ = R([1])
    print get_memory_usage() - m

leak(10000)

@williamstein williamstein added this to the sage-2.8.2 milestone Aug 18, 2007
@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Aug 18, 2007

comment:6

after much hunting, the bug appears to be in PARI gen __bool__ method, which currently is implemented as:

def __bool__(gen self):
   _sig_on
   t = bool(self.g != stoi(0))
   _sig_off
   return t

which doesn't make a whole lot of sense.

@williamstein
Copy link
Contributor

comment:8

This is really a symptom of some sort of much more general memory leak problem in the PARI C library interface, as the following bizarre example illustrates:

sage: n = pari('x')
sage: m = pari(0)
sage: s = get_memory_usage()
sage: for i in range(2*10^5):
...       _ = pari(0)
...
sage: print get_memory_usage() - s
0.0
sage: n = pari('x')
sage: m = pari(0)
sage: s = get_memory_usage()
sage: for i in range(2*10^5):
...       _ = n == m
...
sage: print get_memory_usage() - s
0.0
sage: n = pari('x')
sage: m = pari(0)
sage: s = get_memory_usage()
sage: for i in range(2*10^5):
...       _ = n == pari(0)
...
sage: print get_memory_usage() - s
10.87109375

tobiasdiez pushed a commit to tobiasdiez/sage that referenced this issue Feb 22, 2024
Add cli option to change the url that grayskull will remover the pypi metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant