[android-developers] Re: OutOfMemoryError when switching orientation

2008-12-02 Thread Noam Wolf
Ok I figured this out with the help of the great DS. Basically the image was too large and the phone was chocking on it. So instead i'm using the BitmapFactory to get a smaller size of the image, no more outOfMemory errors! On Dec 1, 8:50 pm, Noam Wolf <[EMAIL PROTECTED]> wrote: > Here is what

[android-developers] Re: OutOfMemoryError when switching orientation

2008-12-01 Thread Noam Wolf
Here is what I commented out and didn't see the OutOfMemory error again: Cursor cursor = getCursor(); ImageView displayImage = (ImageView) findViewById(R.id.belongsImage); try { if (cursor.moveToFirst()) { Line 1: String imageUri = cursor.getString(0); Line 2: displayImage.setImageURI(U

[android-developers] Re: OutOfMemoryError when switching orientation

2008-12-01 Thread Noam Wolf
I'm not explicitly passing context around at all but I am using a ContentProvider which calls getContext()... is that something I should be handling too? On Dec 1, 1:23 am, Romain Guy <[EMAIL PROTECTED]> wrote: > > Always delete references to Context or > > anything that you passed the context to

[android-developers] Re: OutOfMemoryError when switching orientation

2008-11-30 Thread Romain Guy
> Always delete references to Context or > anything that you passed the context to on clean-up. It's a huge one. Just to emphasize this: leaking a Context means you will leak *all* the views and *all* the resources attached to these views (bitmaps, text, etc.) -- Romain Guy www.curious-creatur

[android-developers] Re: OutOfMemoryError when switching orientation

2008-11-30 Thread Robert Green
Here's what I do for my apps and it has solved all resource issues: In each activity I have in onDestroy(), I do the following: Release/clear all resources which have a release() or clear() method. Set all references to null. When I write a custom view or any large data structure, I always a

[android-developers] Re: OutOfMemoryError when switching orientation

2008-11-30 Thread Romain Guy
> I don't understand what's hogging the memory since the image is > already on the device, it's not being copied... The image is stored on the device, but you still have to load it in RAM. > Is there something I should do to the ImageView to clear out it's > bitmap or something? There is nothin

[android-developers] Re: OutOfMemoryError when switching orientation

2008-11-30 Thread Noam Wolf
I'm seeing the exact same error only I'm not even storing an image. I have an ImageView that loads an image from the users picture gallery on the phone, once the image is loaded using setImageUri() when I change orientation I get the exact same error songs described. I don't understand what's ho

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-13 Thread songs
I think we might be talking about a couple of different things. I've got a handle on the leak. What I'm saying is that there seem to be side-effects that change the assumptions of how the think about the lifecycle. From the perspective of the lifecycle and side-effects, I would have expected hi

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-13 Thread hackbod
You need to make sure you have cleaned up everything by the time you return from onDestroy(). If you do that, there will not be a leak. On Oct 13, 1:46 pm, songs <[EMAIL PROTECTED]> wrote: > This is a little confusing then, though.  The animation thread dies as > expected when I stop the applica

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-13 Thread songs
This is a little confusing then, though. The animation thread dies as expected when I stop the application using the back arrow, but does not die (without being explicitly killed) when I flip the orientation. So some extra cleaning up must be happening for one that isn't happening for the other.

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-12 Thread hackbod
onCreate -is- called when the activity is starting fresh. When an orientation switch happens, the old activity is removed through onPause()->onStop()->onDestroy(), and a new instance created in the new orientation. On Oct 11, 10:15 pm, songs <[EMAIL PROTECTED]> wrote: > Tracked the leak down to

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-11 Thread songs
Tracked the leak down to my animation thread which was getting recreated on every onCreate. From the lifecycle docs, I had thought that onCreate only got called when the activity was starting fresh and any old instances had died (and killed everything associated with it). Since this apparently i

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-10 Thread songs
Nope, the only static variables I have are constants. I do keep an array of Drawable in the view, but that's an instance variable. On Oct 10, 1:14 am, "Romain Guy" <[EMAIL PROTECTED]> wrote: > Looks like you're leaking memory somewhere. Do you keep a static cache > somewhere in your app? > > > >

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-10 Thread Romain Guy
Then you should check carefully where exactly you pass your Activity (or Context) to other classes/APIs, etc. The Context is used by many different classes in the Android framework and if you somehow "leak" the Context, you leak all the views, images, etc. Your issue is very similar to several iss

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-10 Thread songs
Interesting. Thanks for the lead. I'll look into this an report back either way. On Oct 10, 1:48 am, "Romain Guy" <[EMAIL PROTECTED]> wrote: > Then you should check carefully where exactly you pass your Activity > (or Context) to other classes/APIs, etc. The Context is used by many > different

[android-developers] Re: OutOfMemoryError when switching orientation

2008-10-10 Thread Romain Guy
Looks like you're leaking memory somewhere. Do you keep a static cache somewhere in your app? On Thu, Oct 9, 2008 at 10:02 PM, songs <[EMAIL PROTECTED]> wrote: > > Hi, > > I think that either I've stumbled onto a bug or I'm missing something > on how to manage my resources. I have an activity wi