Memory leak in instances of SwipeView #13

Closed
myok12 opened this Issue Mar 13, 2012 · 3 comments

Projects

None yet

2 participants

@myok12

During debugging of my webapp, I traced a memory leak to SwipeView code.

the cause of the leak is that customEvents array is not actually being cleared in the destroy method.
The reason is that customEvents is declared on the prototype, while in the destroy, the "this.customEvents = [];" runs on the instance object; it actually creates a new property on the instance object named customEvents that masks the same property on the prototype. The problem is that the this.customEvents.push happening before destroy() (= all of them) are adding references into the prototype and therefore are never being cleared.

The simplest solution, IMHO, is to hoist the customEvents property to the instance level (in the constructor); a bit less tangible, but more prudent. I would also hoist the other instance-level properties (currentMasterPage, x, page, pageIndex), if they did mean to act on the instance level.

@cubiq
Owner

thanks for the detailed report. I'll look into this asap

@cubiq cubiq added a commit that referenced this issue Mar 23, 2012
@cubiq memory leak on destroy #13 c0e15f6
@cubiq
Owner

would you check the latest commit?

@cubiq cubiq closed this Mar 23, 2012
@mwidmann mwidmann added a commit to mwidmann/SwipeView that referenced this issue Mar 30, 2012
@mwidmann mwidmann Merge remote-tracking branch 'upstream/master'
* upstream/master:
  memory leak on destroy #13
  set transition duration proportionally to the remaining distance
  Fixed misspelled css property

Conflicts:
	src/swipeview.js
3311416
@myok12

Did not get an email about your code changes. sorry. Checked it just now and commented on the changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment