When a mobile ListView widget is placed into a different widget and data bound to the ListView by MVVM mechanism, while updating the data, memory leaks occurring. If a small piece of data is updated every second, one megabyte of memory leaking every two seconds. I discivered how to fix it. To do this, change the code of the refresh() method as follows:
if (e.action === "itemchange") {
data = e.items[0];
item = $(that.template(data));
element.find("[data-" + kendo.ns + "uid=" + data.uid + "]").replaceWith(item);
/* Add this lines */
if (data.toJSON) {
data = kendo.observable(data.toJSON());
}
/* the end */
that.trigger("itemChange", {
item: item,
data: data,
ns: ui
});
that._style();
return;
}
It is important that the property "uid" of the object "data" being different from the same property of the object e.items[0] contained in the event.
if (e.action === "itemchange") {
data = e.items[0];
item = $(that.template(data));
element.find("[data-" + kendo.ns + "uid=" + data.uid + "]").replaceWith(item);
/* Add this lines */
if (data.toJSON) {
data = kendo.observable(data.toJSON());
}
/* the end */
that.trigger("itemChange", {
item: item,
data: data,
ns: ui
});
that._style();
return;
}
It is important that the property "uid" of the object "data" being different from the same property of the object e.items[0] contained in the event.