Problem
When you scroll through a table view with image, memory runs low and application eventually hangs.
Sample Code
Consider the following code, and download the attached iproducts.png to your resources directory:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var rows = [];
for (var i = 0; i < 200; i++) {
var row = Ti.UI.createTableViewRow();
row.add(Ti.UI.createLabel({ text: 'Row ' + i, left: 70 }));
row.add(Ti.UI.createImageView({ image: 'iproducts.png', left: 10 }));
rows.push(row);
row = null;
}
win.add(Ti.UI.createTableView({
data: rows,
bottom: 50
}));
var freeMemory = Ti.UI.createLabel({
height: 50, bottom: 0
});
setInterval(function() {
freeMemory.text = 'Free Memory: ' + Ti.Platform.availableMemory;
}, 1000);
win.add(freeMemory);
win.open({
modal: true,
modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
});
Steps To Reproduce
1. Drop the above in an app.js
2. Download the attached iproducts.png to your Resources directory
3. Run the app on device
4. Slowly scroll through the whole table, making sure all of the rows are loaded.
Actual Result:
Application hangs by row 7
Expected Result:
To load the table without hanging
Note: Also occur in 1.8.0.1
Added log for Droid 2.2.3 1.8.1.v20120127113107 V8 test.
Can this be re-tested against master. We landed a fix to address proxies not getting cleaned up. Also I notice in the sample code when you create the row, you don't set a className. On Android if you don't give the rows this property it can consume lots of memory especially when the row count is large.
Brief update: Tested three scenarios with 1.9.0.v20120207171634 (r660b5077) with Nexus S OS 2.3.6 1. Code as is - issue still exists 2. Code with Josh's recommendation of adding a className to each table view row - issue doesn't exist on v8 3. Same as #2 but with rhino - app still hangs at times but doesn't cause low/run out of memory issues
Need more information on #3. When the app hangs does it hang forever or print a stack trace? How long does the app have to be used before the hang?
This issue has been resolved as part of another memory leak fix TIMOB-7409.
Closing issue Tested with Ti Studio build 1.0.8.201201262211 Ti Mob SDK 1.9.0.v20120209183134 OSX Lion 10.7.3 Nexus S OS 2.3.6 Verified that adding a class name to table view row creation causes this issue to not exist