I'm running an app in a 4.2 Nexus 7 device. It has 64 mb app memory. I have 2 activities - and a button to toggle between them. When I start activity A, then B, then A, B, A, B, etc. After a while I get an out of memory error.
I investigated this problem with a heap dump and the memory analysis tools. I found that, basically, the problem is, that the main view - instances of these activities, are kept in memory- and instantiated again and again every time I start this activity! Concretly: - In activity A I have a coverflow instance, which is basically a Gallery with some 3d effect. - In activity B I have a gridview If I switch let's say 8 times between A and B, the heap analysis shows me that 8 instances of coverflow, and 8 instances of gridview are in memory! Each occupying ~1.4 mb BTW: I'm using images, but these are managed by universal image loader library, which I have used frequently now and doesn't seem to cause problems / leaks. Also, the bitmap - occupied space shown by the memory analysis is small. The big issue are these instances of coverflow and gridview. I'm not retaining these instances in static variables or anything. I don't know why they are kept in memory. I also added System.gc calls and method to clear the memory cache of the image loader library - but this doesn't help. Since the main problem seem to be that these instances are "retained" (although I don't know how/where), I understand that gc doesn't help. So, after the users switch screens a while, they get an out of memory. How can I solve this? I went through many option of the memory analysis but didn't find anything that tells me, where/how/when these instances are retained. Thanks in advance. -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

