On MacBook Air Mid 2012, with Sage 9.2,

39

0

memory usage 10k: 5.0

0

memory usage 20k: 11.0

On Thursday, March 18, 2021 at 10:01:56 AM UTC-5 David Joyner wrote:

> On Thu, Mar 18, 2021 at 6:56 AM Maarten Derickx <m.derick...@gmail.com> 
> wrote:
>
>> Hi All,
>>
>> tldr: the bottom of this post contains example code of which I would like 
>> the results on some other systems.
>>
>> I recently encountered a memory leak in the relatively innocently looking 
>> code:
>>
>> d = 27
>> M = 109
>> for i in range(10000):
>>     for a in srange(M):
>>         for r in srange(d):
>>             tmp = r*a
>>
>> However it doesn't seem to be on all platforms that sage supports. For 
>> example on cocalc (ubuntu 20.04) one gets:
>>
>> ~$ 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: import gc 
>> ....: gc.collect() 
>> ....: mem = get_memory_usage() 
>> ....: d = 27 
>> ....: M = 109 
>> ....: for i in range(10000): 
>> ....:     for a in srange(M): 
>> ....:         for r in srange(1,d): 
>> ....:             tmp = r*a 
>> ....: gc.collect() 
>> ....: print("memory usage 10k:", get_memory_usage(mem)) 
>> ....: mem = get_memory_usage() 
>> ....: for i in range(20000): 
>> ....:     for a in srange(M): 
>> ....:         for r in srange(1,d): 
>> ....:             tmp = r*a 
>> ....: gc.collect() 
>> ....: print("memory usage 20k:", get_memory_usage(mem)) 
>> ....:                                                                    
>>                                                  
>> 434
>> 0
>> memory usage 10k: 9.15234375
>> 0
>> memory usage 20k: 21.3984375
>>                     
>>
>> showing clear indication of a memory leak. While on my own laptop (OS X 
>> 10.13.6) I get:
>>
>>
>>
>> ~ mderickx$ sage
>> ┌────────────────────────────────────────────────────────────────────┐
>> │ SageMath version 9.2, Release Date: 2020-10-24 │
>> │ Using Python 3.8.5. Type "help()" for help. │
>> └────────────────────────────────────────────────────────────────────┘
>> sage: import gc
>> ....: gc.collect() 
>> ....: mem = get_memory_usage() 
>> ....: d = 27 
>> ....: M = 109 
>> ....: for i in range(10000): 
>> ....:     for a in srange(M): 
>> ....:         for r in srange(1,d): 
>> ....:             tmp = r*a 
>> ....: gc.collect() 
>> ....: print("memory usage 10k:", get_memory_usage(mem)) 
>> ....: mem = get_memory_usage() 
>> ....: for i in range(20000): 
>> ....:     for a in srange(M): 
>> ....:         for r in srange(1,d): 
>> ....:             tmp = r*a 
>> ....: gc.collect() 
>> ....: print("memory usage 20k:", get_memory_usage(mem)) 
>> ....:  
>> 278 
>> 0 
>> memory usage 10k: 0.0 
>> 0 
>> memory usage 20k: 0.0 
>>
>>
>> so here the memory leak does not occur. However I don't have any other 
>> systems to which I have access to. So I was wondering if people could 
>> execute the code below on some other systems and report back here to see 
>> where the leaking is actually occurring. Since I do not have access to a 
>> plain vanilla sage install on ubuntu, *I am especially interested if on 
>> ubuntu the non cocalc enhanced version of sage also produces a memory leak 
>> for the following code:*
>>
>> import gc
>> gc.collect()
>> mem = get_memory_usage()
>> d = 27
>> M = 109
>> for i in range(10000):
>>     for a in srange(M):
>>         for r in srange(1,d):
>>             tmp = r*a
>> gc.collect()
>> print("memory usage 10k:", get_memory_usage(mem))
>> mem = get_memory_usage()
>> for i in range(20000):
>>     for a in srange(M):
>>         for r in srange(1,d):
>>             tmp = r*a
>> gc.collect()
>> print("memory usage 20k:", get_memory_usage(mem))
>>
>>
> This is in sage 9.1.rc5 running on ubuntu 20.4 on a dell inspiron laptop. 
> It's an old version of sage but I hope it helps:
>
>
>  sage: gc.collect() 
> ....: mem = get_memory_usage() 
> ....: d = 27 
> ....: M = 109 
> ....: for i in range(10000): 
> ....:     for a in srange(M): 
> ....:         for r in srange(1,d): 
> ....:             tmp = r*a 
> ....: gc.collect() 
> ....: print("memory usage 10k:", get_memory_usage(mem)) 
> ....: mem = get_memory_usage() 
> ....: for i in range(20000): 
> ....:     for a in srange(M): 
> ....:         for r in srange(1,d): 
> ....:             tmp = r*a 
> ....: gc.collect() 
> ....: print("memory usage 20k:", get_memory_usage(mem)) 
> ....:  
> 176 
> 0 
> memory usage 10k: 10.0546875 
> 0 
> memory usage 20k: 21.3984375
>
>
>
>> -- 
>> 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+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-devel/5882460b-842c-49c4-b33b-fae1c7986db9n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sage-devel/5882460b-842c-49c4-b33b-fae1c7986db9n%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/8258ffc1-b2b6-4cb2-8e00-c001b3d49e47n%40googlegroups.com.

Reply via email to