Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3150] iOS: UI - tableViewRow backgroundImage not released from memory

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2011-12-29T04:30:03.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterLothar James Foss
AssigneePaul Dowsett
Created2011-08-31T13:07:24.000+0000
Updated2016-03-08T07:48:13.000+0000

Description

Problem

Memory is not being released when navigating between Windows that contain TableViews, made up of rows with a custom backgroundImage. The problem first became evident when we did "on device" testing with an iPod Touch 4G, and did not show up in the simulator.

Test case

Using the code below, navigate numerous times between 'First Window' and 'Second Window', and the app will crash. We originally detected the problem by using Instruments, however I have included an "Available memory" label, which also shows the memory leak in action. By simply commenting out the line backgroundImage:'tablerow.png', memory is again released as expected.
//Create a window with a button, and a label to show available memory
var memoryLabel = Ti.UI.createLabel({
	height:132,
	text:'',
	width:276
})

var openButton = Ti.UI.createButton({
	height:44,
	title:'Open Second Window',
	width:276
});
openButton.addEventListener('click', openSecondWindow); //When the button is clicked open a new window

var firstWindow = Ti.UI.createWindow({
	backgroundColor:'#fff',
	layout:'vertical',
	title:'First Window'
});
firstWindow.add(memoryLabel);
firstWindow.add(openButton);

//Add the window to a navigation group
var navGroup = Ti.UI.iPhone.createNavigationGroup({
	window:firstWindow
});

//Add the navigation group to a main application window, and open it
var appWindow = Ti.UI.createWindow();
appWindow.add(navGroup);
appWindow.open();

//Display the initial amount of available memory
updateMemoryLabel();


//Open a new window that contains a tableView with 60 rows
function openSecondWindow()
{
	var tableData = [];
	
	//Create 60 tableView rows with background images 
	for (var i = 0; i < 60; i++)
	{
		var tableViewRow = Ti.UI.createTableViewRow({
			backgroundImage:'tablerow.png',
			height:100
		});
		
		tableData.push(tableViewRow);
	}

	//Create a tableView and add the rows to it
	var tableView = Ti.UI.createTableView({
		separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE
	});
	tableView.setData(tableData);

	//Create a window, and add the tableView
	var secondWindow = Ti.UI.createWindow({
		backgroundColor:'#fff',
		title:'Second Window'
	});
	secondWindow.addEventListener('close', updateMemoryLabel); //When the window is closed, update the available memory display
	secondWindow.add(tableView);	

	//Open the new window
	navGroup.open(secondWindow);
}

//Update the label that shows available memory in First Window 
function updateMemoryLabel()
{
	memoryLabel.text = "Available Memory: " + Ti.Platform.availableMemory;
}

Attachments

FileDateSize
Images.zip2011-08-31T13:07:24.000+000073216

Comments

  1. Paul Dowsett 2011-12-29

    Lothar Thank you for raising such a complete ticket. I have been told that this issue been fixed in the latest release, although I cannot find the specific ticket. Would you mind testing your code with 1.8.0.1. If it still persists, then I will escalate this to our engineering team. I will mark this resolved for now. Please reopen it once it is complete, and I will move it to the main project. Thanks
  2. Paul Dowsett 2012-02-17

    Closing due to inactivity. If this issue still exists, please raise a new ticket, including all the information in the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) to ensure that we can escalate it quickly. Read [How to Submit a Bug Report](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report) if you have not read it before, and always start a ticket using the [JIRA Ticket Template](https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template). Thanks in advance

JSON Source