googlearchive / polymer-gestures

84 stars 27 forks source link

Mouse move on any page with polymer on it increases memory over time #22

Closed ebidel closed 10 years ago

ebidel commented 10 years ago

Related to https://github.com/Polymer/CustomElements/issues/117

  1. Open the devtools timeline on: http://www.polymer-project.org/docs/elements/ (or any page with polymer on it)
  2. Move the mouse around on the page over a period of time

Memory increases as the mouse continues to move. Presumably this is from polymer-gestures attaching a mousemove listener to the document?

@azakus are there any options here?

dfreedm commented 10 years ago

This is not a memory leak, just a bunch of temporary gesture objects. GC eventually blows them away.

This is due to pumping the gesture queue with mousemoves when the button is not down. Should be easy to fix.

dfreedm commented 10 years ago

Ok, after analyzing this a bit further, the JS Heap is increasing because V8 has to allocate a JS event object for the MouseEvent. I'm told that Events are only collectable at Major GC time, so they stick around a while until they are cleaned up by a Major GC.

The memory pressure is perhaps as high as 1 or 2 MB for many, many mouse moves in a short time, which is incredibly minor.

I don't feel that this warrants the work to make the mousemove listener conditional.