Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12289] Android: Memory leak when a view event listener references a parent

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-02-09T01:12:26.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.1.0, 2013 Sprint 03 Core, 2013 Sprint 03
ComponentsAndroid
Labelsn/a
ReporterAllen Yeung
AssigneeAllen Yeung
Created2013-01-15T13:22:10.000+0000
Updated2013-02-26T11:44:32.000+0000

Description

Reproduction steps: 1. Run the app attached 2. Navigate through the windows 3. Go back to the home screen with 'open 2nd window' 4. Repeat steps 2&3 and see the memory grow in DDMS Actual Results: The allocated memory keeps growing when you are at the home screen Expected Results: The allocated memory should not keep growing and growing

Attachments

FileDateSize
Demo.zip2013-01-15T13:22:10.000+00005844324

Comments

  1. Allen Yeung 2013-01-16

  2. Allen Yeung 2013-01-17

    Updated test instructions: 1. Run the code:
       var win = Ti.UI.createWindow({
       	fullscreen : true
       });
       
       var button = Ti.UI.createButton({
       	title : 'open window'
       });
       
       button.addEventListener('click', function() {
       	var win2 = Ti.UI.createWindow({
       		backgroundColor: 'white',
       		fullscreen: true
       	});
       
       	win2.buffer = Ti.createBuffer({
       		length : 250 * 1024
       	});
       
       	var previousView = Ti.UI.createView({});
       	win2.add(previousView);
       
       	for (var i = 0; i < 10; i++) {
       		var view = Ti.UI.createView({});
       		view.addEventListener('click', function() {
       			win2.backgroundColor = 'blue';
       		});
       		previousView.add(view);
       		previousView = view;
       	}
       	win2.open();
       });
       
       win.add(button);
       win.open();
       
       
    2. Hit open window and back 3. Watch the allocated memory grow in DDMS Expected results: The allocated memory should be relatively the same Actual Results: The allocated memory grows.
  3. Allen Yeung 2013-02-06

    PR: https://github.com/appcelerator/titanium_mobile/pull/3844
  4. Paras Mishra 2013-02-26

    Allocated memory is relatively same. Verified on: SDK version: 3.1.0.v20130225195538 CLI version : 3.0.24 OS : MAC OSX 10.7.5 XCode : 4.5.1 Studio : 3.0.2.201302041757

JSON Source