Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Virtual Tile List: Possible memory leak in documented use

Re virtual tile list guide.

I was wondering why I was getting an ever-increasing number of touch listener events. Whenever a tile got reused, the previous listener remained so two events got triggered for one touch. When the list is scrolled up and down many times, any one tile gets reused multiple times so you can get heaps of events triggered by a single touch.

I think the problem is that the documentation suggests using addEventListener. This means that an ever-lengthening chain of listeners gets created, probably preventing virtual tiles from being garbage-collected. Eventually the app would run out of memory and crash.

The solution seems to be to use onclick rather than addEventListener(). onclick replaces any previous listener, instead of adding another one to the chain.

If this is right, it would be good if the documentation could be updated.

Peter McLennan
Gondwana Software
Best Answer
1 REPLY 1

oh great catch! thanks

Best Answer