1. Drop the following in an app.js
2. Load up DDMS and watch the Allocations or Sysinfo / Memory usage.
3. Touch the "Create big table view" button in the app; a table view with 1500 rows will be created.
4. Refresh the sysinfo and see how the memory footprint has grown.
5. Hit the "Back" button in the app; the window is closed and the variables nullified.
6. Refresh the sysinfo and see that the memory footprint hasn't changed.
7. Repeat steps 3-7 and the memory footprint will only continue to grow.
var win = Ti.UI.createWindow({ backgroundColor:'#fff' });
var btn = Ti.UI.createButton({
color: 'black', layout:'center',
title: 'Create big table view'
});
win.add(btn);
win.open();
btn.addEventListener('click', function() {
var newWin = Ti.UI.createWindow({
backgroundColor: '#fff',
layout:'vertical'
});
var back = Ti.UI.createButton({
color: 'black', top: 10,
title: 'Back'
});
newWin.add(back);
var tv = createBigTableView();
newWin.add(tv);
newWin.open();
function clickListener() {
back.removeEventListener('click', clickListener);
newWin.close();
tv.data = null;
tv = null;
newWin = null;
back = null;
}
back.addEventListener('click', clickListener);
});
function createBigTableView() {
var data = [];
for (i = 1; i <= 1500; i++) {
data.push(createCustomTableViewRow('RowsNMore', i));
}
return Ti.UI.createTableView({
top:0, bottom:0, left:0, right:0,
separatorColor: 'white',
data: data
});
}
function createCustomTableViewRow(label1text, label2text) {
var row = Ti.UI.createTableViewRow({ className: 'customTVRow' });
var vw = Ti.UI.createView({layout: 'vertical'});
row.add(vw);
vw.add(Ti.UI.createLabel({
text: label1text, color: 'black',
font: {fontSize: '9pt', fontWeight: 'bold'}
}));
vw.add(Ti.UI.createLabel({
text: label2text, color: 'gray',
font: {fontSize: '7pt', fontWeight: 'normal'}
}));
return row;
}
Pull request: https://github.com/appcelerator/titanium_mobile/pull/522
Verified fix on a Nexus One running 2.2.2 and an HTC Evo 4G running 2.3.3 with SDK 1.8.0.1.v20111122105459. Memory usage increases when rows are created and decreases when the back button is pressed.
Reopening as Valid. SDK: 1.8.1.v20120125154634 Android: V8 Studio: 1.0.8.201201210622 OS: Lion Devices Tested: Nexus One 2.2.2, Amaze 2.3.4, Galaxy Tab 10.1 3.1 This test-case causes the app to crash after about 2-4 runs, depending on the device. The memory footprint continues to grow in DDMS. This code cannot be tested in 1.8.0.1 due to TIMOB-6809. There is no crash nor significant memory allocation in 1.7.5, though the fix was supposed to be in 1.8.0. Device Results: Nexus One: Crash. Amaze: Runtime error, freeze, then crash. Galaxy Tab 10.1: Freeze, then crash.
This but cannot be tested in 1.8.0.1 due to TIMOB-6809.
Attached screenshot and crash log for Amaze 2.3.4 V8 1.8.1 crash.
1500 rows is a bit much for tableview. I tested with 500 rows and GC is cleaning up- this is done rather slowly at times but GC is collecting the table. It'd be best if QE can run customer app against latest CI build to see if memory is still an issue.
Duplicate of 7409
Closing ticket as duplicate and links to the related ticket have been provided above.