Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15906] iOS: NavBarButton memory leak

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 3.1.3
Fix Version/sn/a
ComponentsiOS
LabelsSupportTeam
ReporterMatej
AssigneeUnknown
Created2013-10-17T11:07:12.000+0000
Updated2018-02-28T20:04:03.000+0000

Description

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

Attachments

FileDateSize
Sn_mka_obrazovky_2013_10_16_o_12_47_58_PM.png2013-10-17T11:07:12.000+000046096

Comments

  1. Mauro Parra-Miranda 2013-10-22

    Hello, You need to clean the elements by yourself. Check this: https://gist.github.com/mauropm/5923980 Best, Mauro
  2. Matej 2013-10-22

    The first thing which I have tried was:
       blueWin.remove(leftOne);
       leftOne = null;
       
    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...
  3. Matej 2013-10-27

    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
        closeBlueWin.addEventListener('click', function(){
               win1.closeWindow(blueWin);
               
               blueWin.remove(leftOne); //[WARN] :   Called remove for [object TiUIButton] on [object TiUIWindow], but [object TiUIButton] isn't a child or has already been removed.
               blueWin.remove(rightOne);
               
               leftOne = null;
               rightOne = null;
               blueWin = null;
           });
       
  4. Mauro Parra-Miranda 2013-10-29

    Hello, did you remove the events listeners for the buttons? BEst, Mauro
  5. Matej 2013-10-29

    As you can see above navBarButtons don't have any eventListeners.
  6. Mauro Parra-Miranda 2013-10-29

    Hello Matej, how do you know that the memory is leaking? How did you test it? Best, Mauro
  7. Matej 2013-10-29

    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
  8. Matej 2013-10-31

    Will this issue opened or not?
  9. Matej 2013-11-06

    ???
  10. Mauro Parra-Miranda 2013-11-24

    Invalid issue.
  11. Matej 2013-11-24

    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

JSON Source