Titanium Community Questions & Answer Archive

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

Howto free memory for huge numbers of ImageViews ?

Hi there,

i'm building a small demo for the iPhone and try to create every 100ms a new image with an ImageView object and animate it from top to the bottom.
Now with my current code i run into serious memory problems (above all when running the app on the device), since it seems that the ImageViews will never be freed.
I tried setting all i know and can to null in the animation complete handler, but no luck until now.
Also it doesn't seem that i have access to the animated object (in this case an ImageView object) in the complete handler; event.source gives me the Animation object itself.

Here my current code:

function createNewOne() {
        var index = Math.floor(Math.random() * images.length);
        var scale = Math.random();
        var imageView = Titanium.UI.createImageView({
                image: files[index],
                height: 70*(scale+0.5),
                width: 150*(scale+0.5),
                top: -100,
                left: (Math.random() * 200) - 20,
                repeatCount: 1
        });
        win.add(imageView);

        imageView.animate({top:height, duration:7500}, function(e) {
            e.source = null;
        });
};

loadImages();
win.open();
setInterval(createNewOne, 100);

All the images are loaded once on startup and available in the images Array.

Someone can please tell me how to release the ImageViews not needed anymore (i.e. finished animation) ?

Thanks a lot.
valley

— asked April 2nd 2010 by Valentin Treu
  • imageview
  • iphone
  • memory
  • mobile
  • problems
0 Comments

1 Answer

  • Did you figure anything out on this? Thanks in advance.

    — answered August 18th 2011 by Ken Rucker
    permalink
    0 Comments
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.