0

I'm using mplfinance module to plot candlesticks. The problem is mplfinance uses too much memory when it generates plots. I have tried the instructions mentioned in free up the memory used by matplotlib but nothing changed and my code is still fulling up my computer memory.Here is my code:

    fig, axlist = mpf.plot(hloc,hlines=hlines,
                   ylabel='Price(USDT)',type='candle', 
                   style='binance',title=my_title,closefig=True,returnfig=True)

any suggestion is highly appreciated.

Ali Moayed
  • 33
  • 5

1 Answers1

0

It would be helpful to see the rest of your code, to see how you are displaying plots and how many. That said, given the above code, when you are done with each plot you might try:

for ax in axlist:
    del ax
del fig

This will save memory, but at the expense of some time (which will anyway not be noticeable unless your are making thousands of plots).

If you are saving your plots to image files (instead of displaying to the screen) then matplotlib.use("Agg") may help as well.

Daniel Goldfarb
  • 6,937
  • 5
  • 29
  • 61