cubiq/SwipeView

Memory leak in instances of SwipeView

Closed this issue · 3 comments

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.

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

would you check the latest commit?

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