Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7027] iOS: View - not all memory is released when a view is removed

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-13T10:33:09.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsiOS
Labelsmodule_memory, qe-testadded
ReporterJon Alter
AssigneeMax Stepanov
Created2012-01-07T21:26:22.000+0000
Updated2012-07-05T15:55:40.000+0000

Description

When a view is removed from the window the proxy is being released as it should, but there is still memory that is not released. See screen shot of instruments.

Steps to repro:

Step 1: run the code below Step 2: have instruments monitoring the allocations of the app Step 3: click the window (views will be added to the window) Step 4: click the window again (those views will be removed from the window) Step 5: with the iOS Simulator selected click Hardware>Simulate Memory Warning Step 6: notice that the view proxies are released but there is still some memory left over that was not there before creating the views Step 7: comment out everything in the click event Step 8: uncomment Ti.UI.createView(); Step 9: run the app and click the window Step 10 notice that the memory used jumps up and is not released
var win = Ti.UI.createWindow({backgroundColor:'white'});
var testView = null;

win.open();

win.addEventListener('click', function(e){
	if(testView){
		win.remove(testView);
		testView = null;
	}else{
		testView = Test.init();
		win.add(testView);
	}
	
	// Ti.UI.createView();
});

var Test = (function(){
	function init(){
		var view = Ti.UI.createView({
			height: 200,
			width: 200,
			bottom: 20,
			backgroundColor:'blue'
		});
		
		for(var i = 0; i < 100; i++){
			view.add( Ti.UI.createView({backgroundColor: 'red'}) );
		}
		
		return view;
	};
		
	return {
		init: init
	}
})();

Attachments

FileDateSize
Screenshot.jpg2012-01-07T21:29:00.000+0000118089

Comments

  1. Wilson Luu 2012-03-15

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120315091738 Titanium Studio, build: 2.0.0.201203142055 xcode: 4.2 Device: iphone 4s (5.0.1)

JSON Source