Thanks Christian!

More specifically, it only concerns the NTL implementation backend. Here is a more direct example

sage: R = PolynomialRing(ZZ, 'x', implementation='NTL')
sage: x = R.gen()
sage: p = x**2 - 3
sage: for _ in range(10000): a = p(2)
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
171648
sage: for _ in range(10000): a = p(2)
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
172968
sage: for _ in range(10000): a = p(2)
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
174552

Vincent

On 23/03/16 15:15, Christian Nassau wrote:
I also found valgrind not very helpful here, but good old
code-dissection leads me to believe that the problem might originate in
the polynomial evaluation in the _richcmp_ routine in

     src/sage/rings/number_field/number_field_element.pyx

That's because the following code shows the same leak:

x = polygen(ZZ)
K = NumberField(x**3 - 2, 'cbrt2', embedding=RR(1.2599))
w = K.gen()
wp = w.polynomial()
app = K._get_embedding_approx(3)
import resource
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
for _ in range(20000): test = wp(app)
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
for _ in range(20000): test = wp(app)
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
for _ in range(20000): test = wp(app)
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

HTH,
Christian


On 23.03.2016 17:17, Vincent Delecroix wrote:
Hello,

Some friend just sent an e-mail to me mentioning a memory leak. Here
is a minimal example

sage: x = polygen(ZZ)
sage: K = NumberField(x**3 - 2, 'cbrt2', embedding=RR(1.2599))
sage: w = K.gen()
sage: import resource
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
180720
sage: for _ in range(10000): test = w > 1
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
183452
sage: for _ in range(10000): test = w > 1
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
184552
sage: for _ in range(10000): test = w > 1
sage: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
185832

The memory usage should *not* grow at all but it does very fast. I am
new to valgrind and was not able to get anything from it. Any help
appreciated.

Vincent



--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to