Created
August 31, 2012 18:27
-
-
Save pec1985/3556938 to your computer and use it in GitHub Desktop.
How to create a simple memory leak with Titanium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var memLeakArray = []; | |
function FirstWindow() { | |
var win = Ti.UI.createWindow({ | |
backgroundColor: '#ccc' | |
}); | |
var btn = Ti.UI.createButton({ | |
title: 'open next', | |
width: Ti.UI.SIZE, | |
height: Ti.UI.SIZE | |
}); | |
win.add(btn); | |
btn.addEventListener('click', function(){ | |
SecondWindow().open(); | |
}); | |
return win | |
} | |
function SecondWindow() { | |
var win = Ti.UI.createWindow({ | |
backgroundColor: '#ccc' | |
}); | |
var btn = Ti.UI.createButton({ | |
title: 'close', | |
width: Ti.UI.SIZE, | |
height: Ti.UI.SIZE | |
}); | |
win.add(btn); | |
for(var i = 0; i < 20; i++) { | |
var l = Ti.UI.createLabel({ | |
top:0, | |
text: 'meh' | |
}); | |
// Memory Leak!!! | |
memLeakArray.push(l); | |
win.add(l); | |
} | |
btn.addEventListener('click', function(){ | |
win.close(); | |
}); | |
return win; | |
} | |
FirstWindow().open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't crash the app isn't it?