var win = Titanium.UI.createWindow({ | |
}); | |
var memPool = Titanium.UI.createWindow({}); | |
memPool.open(); | |
memPool.hide(); | |
var memView = Titanium.UI.createView({ | |
size : { | |
width : 320, | |
height : 40 | |
}, | |
bottom : 0, | |
backgroundColor : "#0f0" | |
}); | |
win.add(memView); | |
var element = function (i) { | |
this.value = i; | |
this.overhead = "LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG STRING"; | |
}; | |
var container = function (count) { | |
this.elements = []; | |
for(var i = 0; i < count; i++) { | |
this.elements.push(new element(i)); | |
} | |
}; | |
var addButton = Titanium.UI.createButton({ | |
title : "Add objects to memory", | |
size : { | |
width : 300, | |
height : 50 | |
}, | |
left : 10, | |
top : 10 | |
}); | |
var removeButton = Titanium.UI.createButton({ | |
title : "Remove objects from memory", | |
size : { | |
width : 300, | |
height : 50 | |
}, | |
left : 10, | |
top : 70 | |
}); | |
var infoLabel = Titanium.UI.createLabel({ | |
text : Ti.Platform.availableMemory, | |
size : { | |
width : 300, | |
height : 30 | |
}, | |
left : 10, | |
top : 130, | |
textAlign : "center", | |
color : "#fff" | |
}); | |
addButton.addEventListener('click', function () { | |
var containerView = Titanium.UI.createView({ | |
elements : new container(40000) | |
}); | |
memView.add(containerView); | |
infoLabel.text = Ti.Platform.availableMemory; | |
}); | |
removeButton.addEventListener('click', function () { | |
win.remove(memView); | |
memView = Titanium.UI.createView({ | |
size : { | |
width : 320, | |
height : 40 | |
}, | |
bottom : 0, | |
backgroundColor : "#0f0" | |
}); | |
win.add(memView); | |
}); | |
win.add(addButton); | |
win.add(removeButton); | |
win.add(infoLabel); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment