- Application Type: mobile
- Titanium SDK: 3.1.1.GA
- Platform & version: iOS 6.1
- Device: iOS Simulator
- Host Operating System: OSX 10.8.4
- Titanium Studio: 3.1.1.201306112235
parent_controller.js:
_.each(category, function(inventory_item, index, list) {
var row = Alloy.createController('inventory_list_row', {
selectedBackgroundColor: '',
data: inventory_item
});
row.destroy();
row = null;
});
Ti.App.fireEvent('checkIn');
inventory_list_row.js:
Ti.App.addEventListener('checkIn', function(e) {
console.info('Checking In: ' + args.data.title);
});
Preface: The above code is watered down to prove a point. I know it's doesn't really do anything, but it does prove problematic.
The code in parent_controller.js can be executed multiple times based upon user interaction in my Titanium Mobile iPad application. If the code above only runs once everything is fine. Each time the code above runs again the previous controllers are some how remaining in memory and are still trapping events.
For example, let's say there are 3 inventory_list_row controllers generated the first time the code is executed. In the console I'll see 3 'Checking In' messages appear as expected. The second time it runs, though, I'll see 6 'Checking In' messages appear in the console, so on and so forth.
Why is this, and what can I do to prevent this? You can see I've tried using .destroy and setting row to null to no avail.