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
}
})();
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)