Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5161] Memory leak in Hello World application

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2017-10-17T19:55:26.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy, Titanium SDK & CLI
Labelsmemoryleak
ReporterYahya Uddin
AssigneeShak Hossain
Created2017-08-28T10:05:55.000+0000
Updated2017-10-17T19:55:26.000+0000

Description

I have the following basic Titanium Alloy application: *index.xml*
    <Alloy>
    	<Window class="container">
    		<Label id="label" onClick="doClick">Hello, World</Label>
    	</Window>
    </Alloy>
*index.js*
    function doClick(e) {
    	Alloy.createController('foo', {}).getView().open();
    }
    
    $.index.open();
*foo.xml*
    <Alloy>
    	<Window>
    		<View class="container">
    			<Label id="label">Some text in the foo controller!</Label>
    		</View>
    	</Window>
    </Alloy>
*foo.js*
    $.cleanup = function cleanup() {
      $.destroy();
      $.off();
      $.foo.removeEventListener('close', $.cleanup); // added per @Sharif AbuDarda suggestion
    };
    
    $.foo.addEventListener('close', $.cleanup);
I then monitored the amount of memory the Android emulator was using DDMS, based on the instructions provided here: http://docs.appcelerator.com/platform/latest/#!/guide/Managing_Memory_and_Finding_Leaks When the application started the number of objects was: *32,188* When I click the button, and then close the new window by pressing back, the number of objects increases to: *32,332* I do this again, it increases to: *32,478* Open and close the window about 8 more times, and it increases to: *34,481* and so on. The issue is even worse if the window has many objects. Note I have tested this on both an Android Emulator (Nexus 4) and a real Android device (Samsung S6). This issues seems to occur on *6.1.X GA* NOTE: I have not yet tested this on iOS yet.

Comments

  1. Sharif AbuDarda 2017-08-29

    Hello, The evidence you showed showing a little memory increase. This much is usually negligible. Also, remove any event in the window before closing window. Thanks.
  2. Yahya Uddin 2017-08-29

    Note that removing the event listener did not seem to fix the issue

JSON Source