Dear sage-devel, Writing cython code, I was having a problem with memory leaks, and I managed to simplify the problem to a simple for loop computing a sum.
If the loop variable a is cdef, everything is fine: sage: %%cython ....: def test_with_cdef_a(int N): ....: cdef long S = 0 ....: cdef int a ....: for a in range(1, N): ....: sig_check() # Check for Keyboard interupt ....: S += a ....: return S ....: sage: %time test_with_cdef_a(10**8) # fast, takes no memory, great CPU times: user 103 ms, sys: 2.64 ms, total: 105 ms Wall time: 106 ms 4999999950000000 As expected, if I forget the "cdef int a" line, it takes longer. But most surprisingly, it uses a *lot* of memory during the computation (40%) and not all of the memory is freed after he computation (30%). sage: %%cython ....: def test_no_cdef_a(int N): ....: cdef long S = 0 ....: for a in range(1, N): ....: sig_check() # Check for Keyboard interupt ....: S += a ....: return S ....: sage: %time test_no_cdef_a(10**8) # this takes a lot of memory (40%) + memory leaks (30% of the memory after computation) CPU times: user 8.36 s, sys: 787 ms, total: 9.14 s Wall time: 9.24 s 4999999950000000 sage: %time test_no_cdef_a(10**9) # this takes a lot of memory (all of it, starts swaping) I am using: $ sage -cython -V Cython version 0.24.1 $ sage -version SageMath version 7.4.beta6, Release Date: 2016-09-24 Are you able to reproduce? Sébastien -- 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.