Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android imageView Memory Leak (random size allocation)

$
0
0

I can't wrap my head around this one, so I've given up and I'm asking for help :)

I have an imageView inside a Window that I remove when the 'back' button inside the app is clicked. If you go back into that window, anywhere from 1 to 3MB is added to the heap. After doing this about 10 times the app runs out of memory and crashes. Here's the code:

var lureimage = Ti.UI.createImageView({
        top:'12%',
        width:'98%',
        height: 'auto',
    });
I select the image based on the previous window selection, so I have to 'dynamically' get the filename. I set the else statement in case the image doesn't exist, it wouldn't load anything on that window if the image didn't exist... Cheap workaround :)
var image = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"/lures/images/" + fileName + ".png");
       if (image.exists())
       {
          lureimage.image = image;
          image = null;
       }
       else 
       currentWin.remove(lureimage);
Now, my back button code (well the parts that have to do with the image anyway)
lureimage.image = null;
currentWin.remove(lureimage);
lureimage = null;
I've tried this several different ways and they all end up with the same error. I tried just removing and null'ing the lureimage view, same thing.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>