Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Release memory Imageview

I have big troubles with memory, I have such imageview:

var img = Titanium.UI.createImageView({

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?

— asked July 24th 2010 by Vitali Virulaine
  • crash
  • memory

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);
    — answered August 20th 2010 by Donald Hughes
  • Up

    — answered July 27th 2010 by Raul Magdaleno
  • I've noticed the same thing, and would also appreciate a solution.

    — answered August 20th 2010 by Donald Hughes
  • 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.

    — answered August 20th 2010 by Kevin Whinnery
    • Okay, it's added. #1613. Thanks for taking a look!

      — commented August 20th 2010 by Donald Hughes
    • It doesn't look like anyone has looked at this yet.

      — commented September 13th 2010 by Donald Hughes
    • It might also be worth noting that the same example using SetInterval in the NimbleKit framework doesn't have the memory problem. So if anyone is just targeting iOS, NimbleKit is looking more and more like the better choice.

      — commented September 13th 2010 by Donald Hughes
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.