Skip to content

Memory leak in srange #31511

@koffie

Description

@koffie

The following shows that there is a huge memory leak in the srange command, at least in the cocalc enhanced version of sage-9.2 on ubuntu 20.04:

~$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Create a "Sage Worksheet" file for the notebook interface.         │
│ Enhanced for CoCalc.                                               │
│ Using Python 3.8.5. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage: M = 3000 
....: import gc 
....: gc.collect() 
....: mem = get_memory_usage() 
....: for i in range(10000): 
....:     R = srange(M) 
....: gc.collect() 
....: print("memory usage 10k:", get_memory_usage(mem)) 
....: mem = get_memory_usage() 
....: for i in range(20000): 
....:     R = srange(M) 
....: gc.collect() 
....: print("memory usage 20k:", get_memory_usage(mem))                                                                   
434
0
memory usage 10k: 884.4296875
0
memory usage 20k: 1770.71875

on my macbook with OS X 10.13.6 there seems to be no problem:

~ mderickx$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Using Python 3.8.5. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage: M = 3000 
....: import gc 
....: gc.collect() 
....: mem = get_memory_usage() 
....: for i in range(10000): 
....:     R = srange(M) 
....: gc.collect() 
....: print("memory usage 10k:", get_memory_usage(mem)) 
....: mem = get_memory_usage() 
....: for i in range(20000): 
....:     R = srange(M) 
....: gc.collect() 
....: print("memory usage 20k:", get_memory_usage(mem))                         
353
0
memory usage 10k: 0.5
0
memory usage 20k: 0.0

on https://groups.google.com/g/sage-devel/c/K4EQiwyIRHQ/m/KzkiondSAQAJ there are confirmations that the problem also exists on Arch linux and the non cocalc enhanced version of sage.

Component: basic arithmetic

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions