Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13852] Android: Application runs out of memory when user scroll the table quickly

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2013-06-20T22:29:54.000+0000
Affected Version/sRelease 3.0.2, Release 3.1.0
Fix Version/s2013 Sprint 13 API, 2013 Sprint 13
ComponentsAndroid
Labelsipass1, supportTeam
ReporterRupesh Sharma
AssigneeIngo Muschenetz
Created2013-05-14T07:15:42.000+0000
Updated2017-03-20T22:00:44.000+0000

Description

Description

In a quite big tableview with around 500 rows when Scrolling the table slowly, there is no problem at all. But on scrolling the table quickly, the app runs out of memory and it crashes

Test Code

Titanium.UI.setBackgroundColor('#000');
 
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
 
var ref_data = new Array();
var rowView="";
var row="";
for (var a=0; a<= 500; a++){
 
                
                row = Ti.UI.createTableViewRow();
                row.selectedBackgroundColor = 'yellow';
                row.backgroundColor = '#FFffff';
 
                row.height = 55;
 
 
                ref_data.push(row); 
 
        }
 
ref_tableView = Titanium.UI.createTableView({
    data:ref_data,
    height:'auto'
    //backgroundColor:'white'
});
 
win1.add(ref_tableView);
 
win1.open();

Attachments

FileDateSize
WP_20130531_001.mp42013-05-31T10:47:33.000+00006590666

Comments

  1. Rupesh Sharma 2013-05-31

    Hi, Please see the attached video depicting the problem.
  2. Ping Wang 2013-06-14

    In the test case, when the table is scrolled, new rows are displayed on the screen so new label proxies are created. This means if the table is scrolled to the end, it needs to create 500 label proxies. That's why OOM happens. When the tableview has a large number of rows, the [className](http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableViewRow-property-className) property is recommended to use. If we give the same className to the rows which have the same layout, our platform can reuse those proxies and only reset the content. This will save a lot of memory and make the tableview perform much better. Example code:
       Titanium.UI.setBackgroundColor('#000');
         
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
         
       var ref_data = new Array();
       var rowView="";
       var row="";
       for (var a=0; a<= 500; a++){
         
                        
                       row = Ti.UI.createTableViewRow({
                       	className: "myRow"
                       });
                       row.selectedBackgroundColor = 'yellow';
                       row.backgroundColor = '#FFffff';
         
                       row.height = 55;
         
         
                       ref_data.push(row); 
         
               }
         
       ref_tableView = Titanium.UI.createTableView({
           data:ref_data,
           height:'auto'
           //backgroundColor:'white'
       });
         
       win1.add(ref_tableView);
         
       win1.open();
       
  3. Hieu Pham 2013-06-20

    Closing as Invalid.
  4. Lee Morris 2017-03-20

    Closing ticket as invalid.

JSON Source