vectorbt icon indicating copy to clipboard operation
vectorbt copied to clipboard

Jupiter notebook : indicators calls cause memory leak ?

Open gaugau3000 opened this issue 4 years ago • 2 comments

hi when i run in a Jupiter notebook this cell many times the memory of python process memory keep growing.

RSI = vbt.IndicatorFactory.from_talib('RSI')
rsi = RSI.run(df['Close'], timeperiod=[14])
NATR = vbt.IndicatorFactory.from_talib('NATR')
natr = NATR.run(df['High'],df['Low'],df['Close'], timeperiod=[14])

del variable_name has no effet.

Any Idea.

Many tks

gaugau3000 avatar Nov 04 '21 17:11 gaugau3000

Jupyter Notebook stores each cell's output in Out variable. Re-running the same cell appends the output to this dict, that's may be a reason. I also tried running your snippet outside of Jupyter and the memory kept constant as expected. To release memory you can use del and then explicitly import gc; gc.collect(). After you do this, objects get destroyed and you won't find them in gc.get_objects().

polakowo avatar Nov 04 '21 18:11 polakowo

Many tks missing the import gc; gc.collect() part. Yes i don't know why the memory keep growing after each time i run this cell in particular (+ 300 Mo per iteration).

gaugau3000 avatar Nov 05 '21 10:11 gaugau3000