It is because the app doesn't actually go away when it ends a lot of times. Android will clean it up when it feels like it. When you restart the app your adding your image again, if you do a heap dump at your force close of the second run your likely to see two instances of whatever class is holding the image. Basically you have a leak of some sort between runs.
This is a good start probably: http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html And you probably want to check this out which will tell you how to perform and analyze a heap dump on the android. http://www.artima.com/forums/flat.jsp?forum=121&thread=256414 I like to go null out all of my event handlers, listener registries and any passed Context values being held by a class. I've been playing around with using weak references for my context values if I hold them at the class level, that allows them to be GCd even if I have a reference to them. The reason it acts differently when using the home key vs. the back key is because when you use home and then hit your app icon your being returned into the still running previous instance, when you hit back key it ends the app but Android will keep the instance around and when you hit your app icon again it restarts it and you had stuff left from the last run that couldn't be GCd and that's why it's blowing up. Try watching it in DDMS it's pretty interesting. They are my least favorite type of error to debug :), good luck. Sean Overby On May 30, 5:40 am, Nick <[email protected]> wrote: > I have an app that I have been working on and it runs fine on the > simulator, but when I load it into my phone it crashes but only on the > second run of it. I'm testing it on an HTC incredible. I think the > logcat line is > 15376 byte external allocation too larger for this process out of > memory heap size = 6599kb allocated 4136kb bitmap size = 17970kb > > I can not seem to catch the exception, It never fails the first time > I launch the app or if i exit using home instead of back. I have > found that when I go back using the back key it goes through > onDestroy() and back to onCreate(), and then crashes. I'm very > puzzled as to why it acts differently...seems like if it goes though > onDestroy next time it loads is like the first time. I think it is > related to a large number of bitmaps I'm creating. > > Thanks, > Nick -- 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

