Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9500] iOS: Table view rows that are not visible on screen should be recycled

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-09-11T04:50:44.000+0000
Affected Version/sRelease 2.0.2, Release 2.0.1
Fix Version/sSprint 2012-14 Core, Release 3.0.0
ComponentsiOS
Labelscore, module_tableviewrow, qe-review, qe-testadded, support
ReporterBetty Tran
AssigneeMax Stepanov
Created2012-06-12T10:57:54.000+0000
Updated2012-09-11T04:50:45.000+0000

Description

Problem

When adding table rows dynamically to a table view and there is a large data set, eventually the application will run out of memory because table rows and their child UI components are never released as more rows are scrolled through and added.

Feature requested

In native iOS the table view rows are recycled so even for large or infinite data sets, there is always a limited number of rows that are in memory at any given time. In Titanium, this is not the case. It is not possible to have an infinite amount of table view rows without the application crashing or degrade in performance.

Comments

  1. Betty Tran 2012-06-12

    Here is the sample app:
       
       var buildRow = function() {
       	var rowView = Titanium.UI.createTableViewRow({
       		className : 'lolcat',
       		layout : "vertical",
       		height : 350,
       		backgroundColor : 'pink'
       	});
       
       	var imgAvatar = Titanium.UI.createImageView({
       		image : 'http://placekitten.com/g/50/50',
       		height : 50,
       		width : 50,
       		top : 5,
       		left : 5
       	});
       
       	rowView.add(imgAvatar);
       
       	var avaLabel = Ti.UI.createLabel({
       		text : "Super Cat",
       		font : {
       			fontSize : 12,
       			fontWeight : 'bold'
       		},
       		top : 5,
       		left : 65
       	});
       
       	rowView.add(avaLabel);
       
       	var imgThingy = Titanium.UI.createImageView({
       		image : 'http://placekitten.com/g/300/200',
       		height : 200,
       		width : 300
       	});
       
       	rowView.add(imgThingy);
       
       	var postTitle = Ti.UI.createLabel({
       		text : "Cat saves the day",
       		font : {
       			fontSize : 18,
       			fontWeight : 'bold'
       		}
       	});
       
       	rowView.add(postTitle);
       
       	var postText = Ti.UI.createLabel({
       		text : "At 12, a helicopter crashed and all passengers were saved by this cat",
       		font : {
       			fontSize : 10,
       		}
       	});
       
       	rowView.add(postText);
       	
       	return rowView;
       }
       
       
       var buildTable = function() {
       	var data = [];
       	var table = Ti.UI.createTableView({
       		top : 0,
       		right : 0,
       		bottom : 0,
       		left : 0
       	});
       
       	for (var i = 0; i < 600; i++) {
       		data.push(buildRow());
       	}
       
       	table.setData(data);
       	
       	return table;
       }
       
       var win = Ti.UI.createWindow({
       	backgroundColor : '#fff'
       });
       
       var table = buildTable();
       
       win.add(table);
       
       win.open(); 
       
       
  2. Max Stepanov 2012-06-26

    PR pending https://github.com/appcelerator/titanium_mobile/pull/2473 Test instructions: Run the example with Instrument and filter for 'TableView'. Should be: - 600 living TiUITableViewRowProxy - 3 living / 0 transitory for TiUITableViewCell, TiUITableViewCellContentView, TiUITableViewRowContainer.
  3. Blain Hamon 2012-07-18

    Pull merged.
  4. Evgenii Tcarev 2012-08-14

    Verified fixed with: Titanium Studio, build: 2.1.1.201207271312 SDK version: 2.2.0.v20120813184911 Devices: iPad3 4G (5.1.1)
  5. Anshu Mittal 2012-09-11

    Reopening to update labels

JSON Source