Skip to content

Memory leak with surface plots #957

Closed
@samuela

Description

@samuela

I'm working in a Jupyter notebook with a number of plotly surface plots. I've noticed that after 4-5 plots are generated, my computer slows down considerably. Upon review, I realized that Chrome was consuming all of my 16gb of memory. Closing the Chrome tab with the plots freed up 12gb of memory.

Here's some simple code that attempts to reproduce the error. Apologies in advance if it crashes your machine.

import numpy as np

import plotly
import plotly.graph_objs as go

import pandas as pd

plotly.offline.init_notebook_mode(connected=True)

for _ in range(50):
    data = [go.Surface(z=np.random.randn(50, 50))]
    layout = go.Layout(
        width=500,
        height=500,
        margin=dict(
            l=65,
            r=50,
            b=65,
            t=90
        )
    )
    fig = go.Figure(data=data, layout=layout)
    plotly.offline.iplot(fig)

Running it once is fine. A chunk of memory is used. No problem. But then if the same cell is reevaluated, removing the previous plots and replacing them with new ones, the memory only continues to climb. (You may need to rerun a few times to get the full effect.) We should expect totally memory usage to remain constant more or less. But things just keep climbing.

I'm running Chrome 53.0.2785.116 on Mac OS X 10.11.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions