Release memory Imageview
I have big troubles with memory, I have such imageview:
var img = Titanium.UI.createImageView({
backgroundImage:'images/text.png',
width:640,
height:880,
left:0,
top:0,
});
When I replace backgroundImage attribute by new one (I do in in cycle), I can see than free memory has significantly decreased, my app even crashes on iPhone.
Is there any way to release the memory? Why it isn't released automatically while image file or url replaced?
4 Answers
-
To clarify, I think my problem only occurs when ran from inside a setInterval. If I simply load 150 images sequentially into an imageview's image, then only 15 MB of real memory is used. However, when performed inside the setInterval's callback, the memory usage escalates to nearly 100 MB and stays at that level throughout subsequent loops. I'm guessing the scope of setInterval is global and won't release any memory until the app is closed. I've also noticed a small memory leak in another place I use setInterval to update a counter.
function updateAnimationCallback() { view.image = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, ar[step]); } setInterval(updateAnimationCallback, 100);
-
Up
-
I've noticed the same thing, and would also appreciate a solution.
-
If anyone could provide a test case of this (a simple app which replicates this problem) and create an issue in our Lighthouse tracking system, we would definitely take a look at it right away.