ipython / ipython/ipython

one-line execute occur memory leak

Open
#14,391 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

https://github.com/jupyterlab/jupyterlab/issues/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
```python
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](https://github.com/ipython/ipython/assets/79349894/86609471-b6a0-42a0-acd9-372790050df6)

Mem usage of windows task mgr.
![image](https://github.com/ipython/ipython/assets/79349894/737f9fb4-baa9-4235-996e-e86a55c43626)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.