dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

Annotations leak memory

Open mjhalme opened this issue 9 years ago • 2 comments

We are adding and removing dozens of annotations per minute. Both are done by modifying an array and then calling setAnnotations. Now we have had problems with heavy memory usage and the annotations seems to be the cause for that.

For me it seems, that annotations plugin leaks memory via event handlers with in two ways:

  1. removeEventListener for div elements is never called
  2. "addAndTrackEvent" pushes events to "registeredEvents_" array, but they are never removed from there.

mjhalme avatar Sep 08 '15 12:09 mjhalme

The event handlers registered via addAndTrackEvent get removed when you call g.destroy(). This make sense for listeners which live as long as the dygraph. But for annotations, which can have shorter lifetimes, you're right that this will leak. I'd be very happy to accept a PR to fix this.

danvk avatar Sep 08 '15 17:09 danvk

Is this a leak? (detached nodes):

image

Legends avatar Dec 28 '16 22:12 Legends