[TIMOB-3799] iOS: in tableView using setData(rows) and data = rows to set the rows keeps all of the previous rows in memory
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-05-11T14:32:21.000+0000 |
Affected Version/s | Release 1.6.0 M10 |
Fix Version/s | Sprint 2011-17 |
Components | iOS |
Labels | n/a |
Reporter | Jon Alter |
Assignee | Reggie Seagraves |
Created | 2011-04-27T19:55:28.000+0000 |
Updated | 2011-05-11T14:32:21.000+0000 |
Description
If you use table.setData(rows); or table.data = rows; the rows that are being overwritten will be saved in memory.
Step 1: run the code below
Step 2: run Instruments search for proxy (see that #Living grows each time and does not release, should release)
Step 3: click the 'Reset Data' button
Step 4: notice that the number of 'Labels' and 'Rows' grows by 100 on every button click
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
function setRows(_start) {
var rows = [];
var end = _start + 100;
for(var i = _start; i < end; i++) {
var row = Ti.UI.createTableViewRow();
var label = Ti.UI.createLabel({ text: "Test " + i });
row.add(label);
rows.push(row);
}
return rows;
}
var table = Ti.UI.createTableView({
data: setRows(0) ,
bottom: 70
});
var button = Ti.UI.createButton({
title: "Reset Data",
height: 50,
width: 200,
bottom: 10
});
var click = 0;
button.addEventListener("click", function() {
click += 100;
table.setData(setRows(click));
// table.data = setRows(click);
});
win1.add(table);
win1.add(button);
win1.open();
Workaround
Did not work in (1.6.2). Worked with (1.7.0 Apr 27 2011 16:40 r3fb01972) here: http://builds.appcelerator.com.s3.amazonaws.com/mobile/master/mobilesdk-1.7.0-20110427164044-osx.zip
win1.remove(table);
table = null;
table = Ti.UI.createTableView({
data: setRows(click) ,
bottom: 70
});
win1.add(table);
Tested with 1.7.0.879871b...(05/10/11 19:34) on iPod 3rd Gen (4.0.1)