Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7399] Android: TableView: Scrolling through a Table View with image causes application to run out of memory and hang

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-02-14T23:29:02.000+0000
Affected Version/sRelease 1.8.1
Fix Version/sSprint 2012-03, Release 2.0.0, Release 1.8.2
ComponentsAndroid
Labelsqe-and012312
ReporterNatalie Huynh
AssigneeJosh Roesslein
Created2012-01-25T13:03:21.000+0000
Updated2012-02-14T23:29:02.000+0000

Description

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

Attachments

FileDateSize
droid 2.2.3 1.8.1 v8.txt2012-01-27T13:49:12.000+0000431929
iproducts.png2012-01-25T13:08:30.000+00002709

Comments

  1. Dustin Hyde 2012-01-27

    Added log for Droid 2.2.3 1.8.1.v20120127113107 V8 test.
  2. Josh Roesslein 2012-02-07

    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.
  3. Michael Pettiford 2012-02-08

    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
  4. Opie Cyrus 2012-02-08

    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?
  5. Neeraj Gupta 2012-02-08

    This issue has been resolved as part of another memory leak fix TIMOB-7409.
  6. Michael Pettiford 2012-02-10

    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

JSON Source