Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one-line execute occur memory leak #14391

Open
TeusEE opened this issue Apr 9, 2024 · 1 comment
Open

one-line execute occur memory leak #14391

TeusEE opened this issue Apr 9, 2024 · 1 comment

Comments

@TeusEE
Copy link

TeusEE commented Apr 9, 2024

jupyterlab/jupyterlab#16139
while i use spyder/Jupyterlab, i found some unintended(i presume) memory leak.

above issue, i try to make list/array inside of python function and return it

but if i try to use the function with one line execution, there happen incresing memory and never decrease

first i think it is problem of spyder/JupyterLab, but same issue occur in IPython Shell in command prompt

i attach code below.

please review

import numpy as np
import gc
cnt = 100000000

def np_gen():
    _ret = np.ones(cnt, dtype = np.int32)    
    try:
        return _ret
    finally:
        while gc.collect():
            print("collect gcing...") 

execute sequence.
image

Mem usage of windows task mgr.
image

case study.
if i use %reset, all variable remove.

%reset out => remove output, but memory never recovered

%xdel => can't remove because output data has no variable name

@Carreau
Copy link
Member

Carreau commented Apr 10, 2024

Interesting.

If someone want to investigate, you might want to use https://objgraph.readthedocs.io/en/stable/ and a weakref to the created object to see what is holing to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants