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

Memory leak in dynamically updated scatter plot. #1755

Closed
adamshapiro0 opened this issue Jun 2, 2017 · 9 comments
Closed

Memory leak in dynamically updated scatter plot. #1755

adamshapiro0 opened this issue Jun 2, 2017 · 9 comments

Comments

@adamshapiro0
Copy link

Hi,

I'm using scatter plots as part of a real-time data display where I'm updating the data set relatively frequently (large volume of data @ ~5-10Hz). I've noticed a significant growth in memory usage as the plot is updated on the order of 100s of MB over a short span of time. I made a small pen to demonstrate, just generating random data and restyling the plot:

https://codepen.io/adamshapiro0/pen/jwOWgZ

I've found a few things after a bunch of digging and googling:

  1. This seems to happen in both Chrome (58.0.3029.96) and Firefox (53.0.3)
  2. The tab's overall memory usage and javascript memory usage as reported by Chrome's task manager grow continuously while the tab is visible
  3. When another tab is selected, the memory usage drops back down to a reasonable level, but appears to maybe grow slowly (hard to tell)
  4. In the Chrome inspector, the heap usage recorded by the profiler appears to drop completely to normal on each garbage collect (i.e., the task manager looks like the usage is growing without bound but the inspector profile and heap snapshots don't match that)

I can't tell if this is an issue with Plotly or a deeper HTML5/v8 issue, but since it seems to affect both browsers I'm leaning towards Plotly.

This might be related to #957 and plotly/plotly.py#487, but it's not quite clear.

Any thoughts?

@etpinard
Copy link
Contributor

etpinard commented Jun 2, 2017

Interesting. This is the first time I hear about a (possible) memory leakage in an SVG-based trace type (#957 and plotly/plotly.py#487 identify problems with the WebGL-based surface trace type).

I remember @alexcjohnson taking about noticing some memory issues in codepen itself that couldn't be replicated in a plain HTML page. @adamshapiro0 have you noticed this leaky behavior outside of codepen?

@etpinard
Copy link
Contributor

etpinard commented Jun 2, 2017

@adamshapiro0 is using restyle in the referenced codepen. I wonder if extendTraces has the same apparent leaky tendencies.

@adamshapiro0
Copy link
Author

(Sorry for the delay - traveling.)

@etpinard, I tried copying the codepen code directly into a local HTML file and I think I'm seeing slow memory growth. It's a bit hard to tell because of variation due to garbage collection, but I watched it for a while and it did at least seem to be growing on average. I can try to play some more to confirm when I have a bit more time.

@dy
Copy link
Contributor

dy commented Jul 5, 2017

If there is memory leak, it is tiny/very hard to catch. 30s memory screening:
image
image
Probably we need better test.

@ghost
Copy link

ghost commented Aug 23, 2017

I am having the same issue with memory growing as I update my chart in plotly. I have tried a few different ways to update the chart using newPlot and deleteTraces / addTraces but I am seeing the memory usage rise in chromes task manager by 100k to 500k every time I try to update my chart with new traces. Anyone have any other suggestions on how to try rebuilding / updating the chart?

@etpinard
Copy link
Contributor

Closing as I'm hoping this thing is obsolete.

@markzolotoy
Copy link

No, it's not. I am seeing memory leak. If I dont execute Plotly.react then it's not happening.

@etpinard
Copy link
Contributor

No, it's not. I am seeing memory leak. If I dont execute Plotly.react then it's not happening.

Can you share a reproducible example to help us debug? Thank you!

@markzolotoy
Copy link

I was wrong about a straight memory leak, however my confusion is based on the following scenario. I have a button that sends a data request to the server and upon data arrival processes the data and renders a chart. Let's assume that data retrieval takes 5 secs and chart rendering (Plotly.react) takes 5 secs too. If I keep clicking the button before data is processed and Plotly.react is executed then I have no memory leak, but once I click the button that will start reprocessing of the unfinished chart it creates a memory leak. That's the impression I am getting.

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

4 participants