[TIMOB-8330] Android: Global variables causing memory leak on windows
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Reopened |
Resolution | Unresolved |
Affected Version/s | Release 2.0.0, Release 1.8.2 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Hieu Pham |
Assignee | Unknown |
Created | 2012-03-27T11:26:27.000+0000 |
Updated | 2018-03-06T18:57:53.000+0000 |
Description
Assigning window to a global variable causes that window to leak when closing via back button.
Steps to reproduce:
1. Run this code:
var mainwin = Ti.UI.createWindow({
title:'TEST WINDOW',
backgroundColor:'#fff',
fullscreen:true,
statusBarHidden: true,
navBarHidden:true,
exitOnClose:true
});
var MY_WINDOW = null;
var button1 = Ti.UI.createButton({
top: 100,
title: "create Window"
});
button1.addEventListener('click', function(e) {
MY_WINDOW = createWin();
MY_WINDOW.open();
//createWin();
});
mainwin.add(button1);
mainwin.open();
function createWin() {
var win = null;
var v = [];
win = Ti.UI.createWindow({
fullscreen:'true',
backgroundColor:'#fff'
});
for (var i=0; i < 600; i++) {
var view1 = Ti.UI.createView();
v.push(view1);
win.add(view1);
}
return win;
//win.open();
}
2. Click on 'create Window' button.
3. Click back
4. Repeat and observe memory in DDMS
NOTE: if you don't assign global variable, then it won't leak. Try moving the open() call into createWin() function and don't return anything.
This issue is due to V8 GC lag. Closing as invalid.