Hi Gonzalo,

I highly recommend using https://github.com/rfjakob/earlyoom instead of
waiting for OOM to kick in.

Cheers,
Edgar

On Wed, Jul 5, 2023 at 11:24 AM Gonzalo Tornaria <torna...@gmail.com> wrote:

> This slowly and inexorably goes on. Computing `sqrt(T2)` leaks 32 bytes
> each and every time (asymptotically).
>
> Found by a student who, through no fault of himself, brought down our
> server (unable to ssh in until the OOM triggered -- but since the leak is
> slow it takes a while to trash 16G of swap).
>
> ===
> $ cat memleak.py
> from sage.all import sqrt
> T2 = sqrt(2)
> import psutil
> ps = psutil.Process()
> base = ps.memory_info().rss
> for a in range(1, 10):
>     for b in range(num := 100_000):
>         C = sqrt(T2)
>     mem = ps.memory_info().rss - base
>     print(f"{mem/1e6 :.2f} MB ({mem/a/num :.2f} bytes/iter)")
> $ sage memleak.py
> 2.70 MB (27.03 bytes/iter)
> 5.95 MB (29.74 bytes/iter)
> 9.19 MB (30.64 bytes/iter)
> 12.44 MB (31.09 bytes/iter)
> 15.41 MB (30.82 bytes/iter)
> 18.65 MB (31.09 bytes/iter)
> 21.90 MB (31.28 bytes/iter)
> 25.14 MB (31.43 bytes/iter)
> 28.39 MB (31.54 bytes/iter)
> ===
>
> Replace the 10 in the outer loop by something larger at your own peril
> (each outer iteration will take 3.2M so 10_000 should kill a laptop in an
> hour or two).
>
> This is with system sagemath 10.0 but it also happens with 9.6, 9.7, 9.8
> and 10.0 in cocalc.com.
>
> Best,
> Gonzalo
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/26ec41f7-c591-48b6-ab57-463b8b8a1675n%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-devel/26ec41f7-c591-48b6-ab57-463b8b8a1675n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CA%2BiQ7x47X70AMHpkzZ10sL7UQs0zPLvjHhAU-Lc2cwjeWGPiVA%40mail.gmail.com.

Reply via email to