Problem Description
When a window is closed, the NavBarButtons should be removed, as well as other objects in the window.
Steps to reproduce
Create a new mobile project
Add this to app.js
var win2 = Titanium.UI.createWindow({
backgroundColor: 'red',
title: 'Red Window'
});
var win1 = Titanium.UI.iOS.createNavigationWindow({
window: win2
});
win2.addEventListener("click", function(){
var leftOne = Ti.UI.createButton({
systemButton: Ti.UI.iPhone.SystemButton.DONE
});
var rightOne = Ti.UI.createButton({
systemButton: Ti.UI.iPhone.SystemButton.DONE
});
var blueWin = Ti.UI.createWindow({
leftNavButton: leftOne,
rightNavButton: rightOne,
backgroundColor: "blue"
});
var closeBlueWin = Titanium.UI.createButton({
title: 'Close Blue Window'
});
closeBlueWin.addEventListener('click', function(){
win1.closeWindow(blueWin);
});
blueWin.add(closeBlueWin);
win1.openWindow(blueWin);
});
win1.open();
Run this in instruments, the memory only grows as you can see in the attached image.
Extra information
Forum:
http://developer.appcelerator.com/question/158445/navbarbutton-memory-leak
Hello, You need to clean the elements by yourself. Check this: https://gist.github.com/mauropm/5923980 Best, Mauro
The first thing which I have tried was:
But it didn't work. I will try it again... Anyway why those buttons are not removed automatically after win.close()? Normal button in the window is removed...
Alright, so I have tried it again and basically it doesn't work for me. Please if this is not a bug can you provide me some solution that work? *As I asked above why those buttons are not removed automatically same as normal button in the window? I think they have to be removed by win.close() otherwise if I have to remove every time, every navButton from different window (+another objects) that is very annoying process. Thanks
Hello, did you remove the events listeners for the buttons? BEst, Mauro
As you can see above navBarButtons don't have any eventListeners.
Hello Matej, how do you know that the memory is leaking? How did you test it? Best, Mauro
You can see it in the picture above (In attachments). Count of NavBarButton is increasing every time when is window opened and it never decrease after win.close(). Normal button that is in the window is alright, only navButtons doesn't work properly... *For test you can use Instruments from Xcode
Will this issue opened or not?
???
Invalid issue.
Hi Mauri, please if this issue is invalid can you provide some solution? As you can see above I tried a lot of things and basically it doesn't work. If you don't have any solution I think this is not invalid... Thank you