I'm developing an app in Titanium that needs to work on android and IOS, but I'm getting some memory problems.
In my app.js file I have this:
var win = Ti.UI.createWindow({
backgroundColor : 'white',
url : 'Home.js'
});
win.open();
Ti.App.View = [];
The Ti.App.View array is tu keep a reference to all my container views along my project so I can close them or check if they are already visible.
Then in my Home.js file I have some buttons to open some views. Ex:
var view = Ti.UI.createView({
height : deviceHeight,
width : deviceWidth,
backgroundColor : 'white'
});
Ti.UI.currentWindow.add(view);
var viewMenu = Ti.UI.createView({
layout : 'vertical',
width : deviceWidth * 0.20,
backgroundColor : 'transparent',
});
view.add(viewMenu);
viewMenu.addEventListener('click', function() {
var Favorites = require("Eventos");
Events.AddLayout();
});
This is the way how I add a new layout to the same window.
Then on my Events.js file I have a function like this and a global event :
exports.AddLayout = function(e) {
//adding all my layout.....
}
Ti.App.addEventListener('Update', function() {
// due something in hear
});
My question is how can I remove all Ti.UI objects created in the AddLayout function from memory when I press back button? And how can I remove the global event created by the Events.js file?
I have tried to reference te container view to null but it has not solved my problem.
Ti.UI
namespace, put them inAlloy.Globals
(if you use Alloy) or even better, make a lib to handle it. – Rene Pot