Re: [android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-15 Thread Sorab Pithawala
Hi there,
@Ralph - I do it my way because it seems to me that multiple calls to
getResources() is generally considered to be a bad thing (read it online),
and like Michael said I want to make sure my next Image loads without fail.
That and the fact that in an actual app, you would indeed have quite a few
calls to getResources(). In fact, previously my code used to be that exact
same line, which is why the app crashed when loading the fourth or fifth
image. Supposedly, the GC does not clear the bitmap that is not on screen
fast enough (not sure if it does it at all).

@Michael - Yes, this is exactly the reason why I have done it this way.

Please correct me if I am wrong about the multiple calls to getResources(),
as I have just recently started Android dev.

I also cache the context by using Context context=getApplicationContext();
as that too is used in my app. Does this leak the context in anyway? I know
its off topic but just want to be clear.

Regards,
Sorab



On 16 September 2011 01:59, Michael A.  wrote:

> Presumably because he needs to recycle the switched out bitmap
> immediately, rather than wait for Android to decide that it has time
> to clean out the old bitmaps.
>
> I've run into this issue a lot myself when working with largish
> bitmaps. The GC for bitmaps is pretty rubbish - especially if your app
> has to run on older phones.
>
> Regards,
>
> Michael A.
>
> On Sep 15, 11:53 am, "Ralph Bergmann | the4thFloor.eu"
>  wrote:
> > Am 15.09.11 06:47, schrieb Sorab Pithawala:
> >
> > > I have made a ZIP file containing the code, XML and a small readme.
> >
> > Why do you do it that way:
> >
> > h1 = BitmapFactory.decodeResource(res, R.drawable.help1_l);
> > ImageView im = (ImageView) findViewById(R.id.helpImage);
> > im.setImageBitmap(h1);
> >
> > and not like this:
> >
> > im.setImageDrawable(getResources().getDrawable(R.drawable.help1_l))
> >
> > take also a look at:
> >
> > http://developer.android.com/resources/samples/ApiDemos/src/com/examp...
> >
> > Ralph
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-15 Thread Michael A.
Presumably because he needs to recycle the switched out bitmap
immediately, rather than wait for Android to decide that it has time
to clean out the old bitmaps.

I've run into this issue a lot myself when working with largish
bitmaps. The GC for bitmaps is pretty rubbish - especially if your app
has to run on older phones.

Regards,

Michael A.

On Sep 15, 11:53 am, "Ralph Bergmann | the4thFloor.eu"
 wrote:
> Am 15.09.11 06:47, schrieb Sorab Pithawala:
>
> > I have made a ZIP file containing the code, XML and a small readme.
>
> Why do you do it that way:
>
> h1 = BitmapFactory.decodeResource(res, R.drawable.help1_l);
> ImageView im = (ImageView) findViewById(R.id.helpImage);
> im.setImageBitmap(h1);
>
> and not like this:
>
> im.setImageDrawable(getResources().getDrawable(R.drawable.help1_l))
>
> take also a look at:
>
> http://developer.android.com/resources/samples/ApiDemos/src/com/examp...
>
> Ralph

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-15 Thread Ralph Bergmann | the4thFloor.eu
Am 15.09.11 06:47, schrieb Sorab Pithawala:
> I have made a ZIP file containing the code, XML and a small readme.

Why do you do it that way:

h1 = BitmapFactory.decodeResource(res, R.drawable.help1_l);
ImageView im = (ImageView) findViewById(R.id.helpImage);
im.setImageBitmap(h1);

and not like this:

im.setImageDrawable(getResources().getDrawable(R.drawable.help1_l))


take also a look at:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.html

Ralph

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-15 Thread A.
Thankyou so much! I hope this will help solve my problem!
I'll let you know

Cheers,
A.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-14 Thread Sorab Pithawala
Hi there,
I have made a ZIP file containing the code, XML and a small readme. Download
from BitmapTest.zip .

Regards,
Sorab



On 14 September 2011 18:56, A.  wrote:

> Hi Sorab,
>
> I have a similar issue: please could you provide
> more code to better undestand the solution that you found?
>
> Thanks,
> A.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-14 Thread A.
Hi Sorab,

I have a similar issue: please could you provide
more code to better undestand the solution that you found?

Thanks,
A.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Out Of Memory Error with Images loaded through XML

2011-09-13 Thread Sorab
Solved the issue by having a separate Bitmap object for each Image and then 
when the user navigates to the next page, decode the next bitmap, show it on 
the ImageView and then recycle the previous one. For eg. in my gotoNext()

switch(index)
{
case 1:
h2=BitmapFactory.decodeResources(res,R.drawable.h2);
im.setImageBitmap(h2);
h1.recycle();
break;
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: out of memory error in android

2011-02-23 Thread TreKing
On Wed, Feb 23, 2011 at 2:30 AM, tonytony wrote:

> My problem is that when using KSOAP2, I can connect to ASP.net web service
> OK, but I only get 'null' as return values.
>

What does this have to do with Android or the original question?


> If your web service is working OK, can you please let me know what you are
> using please?
>

I do not have a web service.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: out of memory error in android

2011-02-23 Thread tonytony
Hi there,

I've been searching forums on Android web services but I'm still
stuck.
My problem is that when using KSOAP2, I can connect to ASP.net web
service OK, but I only get 'null' as return values.

If your web service is working OK, can you please let me know what you
are using please?
Thanks

On Feb 23, 2:37 am, TreKing  wrote:
> On Sat, Feb 19, 2011 at 3:12 AM, vijay kumar 
> wrote:
>
> > mywebservice value is very long .
>
> i am using dom parser for parsing the value  while replacing the value I am
>
> > getting out of memory error
>
> Don't use DOM for very large data. Try a pull parser.
>
> --- 
> --
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Out of memory error While loading lot of images from sdcard ?

2011-02-15 Thread gjs
Hi,

http://developer.android.com/reference/android/graphics/Bitmap.html#recycle()

Regards

On Feb 15, 5:32 pm, canny  wrote:
> Hi all,
>
> In my application , I have to display a large image using number of
> small images ( like gogle map tiling of views) . Exactly i need to
> draw all thes bitmaps on canvas at every time am loading images that r
> visible screen i.e while am scrolling updating new set of images . But
> some times getting a problem like out of memory error. Can any one
> tell me how to accomplish my task i.e i have to google map kind of
> view which has to scrolled horizontally and vertically and it has to
> be zoomed too. So please can any one help me to resolve this .
> Thanking u ?
>
> Thanks,
> Srinivas

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: out of memory error

2010-12-10 Thread Brill Pappin
Of course.
Don't load so much data into memory.


i can't actually give you a "solution" to some code I have no idea what
it does, except that is gets pushed into a buffer.
Whatever your doing with that content, you obviously need to process it
in smaller chunks.


- brill

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: out of memory error

2010-12-09 Thread Narendra Bagade
yes you are right,can u suggest me any solution.
thanks

On Fri, Dec 10, 2010 at 1:20 PM, Brill Pappin  wrote:

> It means you ran out of memory...
>
> From the stack trace I'd say your building a large string from a database
> and your reaching your memory limit for the device.
> You can see, the last thing happening before you run out of memory is the
> buffer trying to make more room for what your appending.
>
> - Brill
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 
Regards,
Narendra
.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: out of memory error

2010-12-09 Thread Brill Pappin
It means you ran out of memory...


>From the stack trace I'd say your building a large string from a
database and your reaching your memory limit for the device.
You can see, the last thing happening before you run out of memory is
the buffer trying to make more room for what your appending.


- Brill

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: out of memory error & getWallpaper

2009-08-28 Thread Sables

Are we not able to reassign Bitmaps? I get OOM just by doing something
like

Bitmap a;

a = network.downloadimage();
a = network.downloadimage();
a = network.downloadimage();// <-- crash

Do I have to :

a.recycle() ;
a= null;

everytime?


On Aug 25, 2:25 pm, freeanderson  wrote:
> I guess nobody reported my case.
> I've solved like below. See my case.
>
> ...
>
> Bitmap dummy = Bitmap.createBitma(1, 1, Config.RGB_565);
>
> Bitmap a = Bitmap.createBitma(100, 100, Config.RGB_565);
> Canvas c = new Canvas(a);
>
> ...c.draw(..) ...
>
> a.recycle();
> c.setBitmap(dummy); // This is key point. Very important to remove
> reference of 'c'.
>
> a = null;
> c = null;
>
> .
>
> Good Luck.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error on eclipse

2009-08-27 Thread Spektor Yaron
i am not sure this is what you need, but eclipse works best with between
256M to 512M
try this when you run eclipse (you will need to change the relevant path of
course):

c:\eclipse3.3\eclipse.exe *-vm c:\sun-java2-5.0\bin\java.exe* -vmargs
-Xms256M -Xmx512M

if that works you can add that line in your eclipse shortcut

On Fri, Aug 28, 2009 at 3:25 AM, human android
wrote:

>
> I was using ADT for debugging and then I get this Internal error: out
> of memory error
>
> Is there any way to avoid this?
> >
>


-- 
Yaron Spektor

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error on eclipse

2009-08-27 Thread QTB QTB

$ eclipse -vmargs -Xmx512M

to increase the max heap size to 512 MB.  You can increase more as needed.

On 8/27/09, human android  wrote:
>
> I was using ADT for debugging and then I get this Internal error: out
> of memory error
>
> Is there any way to avoid this?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-24 Thread freeanderson

I guess nobody reported my case.
I've solved like below. See my case.

...

Bitmap dummy = Bitmap.createBitma(1, 1, Config.RGB_565);

Bitmap a = Bitmap.createBitma(100, 100, Config.RGB_565);
Canvas c = new Canvas(a);

...c.draw(..) ...

a.recycle();
c.setBitmap(dummy); // This is key point. Very important to remove
reference of 'c'.

a = null;
c = null;

.

Good Luck.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-22 Thread sameer

Hi,

I am getting the following logs when i am changing the wallpaper for
Homescreen.

Even i am recycling the bitmap is done when the wallpaper changes in
OnWallpaperChanged(). Still i m getting the bellow error.

03-26 05:02:16.829: INFO/AC(1340): setWallpaper(InputStream
03-26 05:02:16.840: INFO/AC(1340): setWallpaper(InputStream,
FileOutputStream)
03-26 05:02:16.889: INFO/WallpaperService(1059): Wallpaper is
changed!!!
03-26 05:02:16.899: INFO/WallpaperService(1059): beginBroadcast()2
03-26 05:02:16.899: INFO/ApplicationContext(1694): com.lge.homecube
03-26 05:02:16.899: INFO/ApplicationContext(1694): applicationContext
is not null
03-26 05:02:16.899: INFO/ApplicationContext(1694): make mWallpaper
null
03-26 05:02:16.909: INFO/WallpaperService(1059): onWallpaperChanged0
03-26 05:02:16.909: INFO/WallpaperService(1059): notifyCallbacks()
03-26 05:02:16.909: INFO/ApplicationContext(1059): android
03-26 05:02:16.909: INFO/ApplicationContext(1059): applicationContext
is not null
03-26 05:02:16.909: INFO/ApplicationContext(1059): make mWallpaper
null
03-26 05:02:16.909: INFO/WallpaperService(1059): onWallpaperChanged1
03-26 05:02:16.909: INFO/WallpaperService(1059): notifyCallbacks()
03-26 05:02:16.989: WARN/dalvikvm(1694): threadid=3: thread exiting
with uncaught exception (group=0x40013e70)
03-26 05:02:16.989: ERROR/AndroidRuntime(1694): Uncaught handler:
thread main exiting due to uncaught exception
03-26 05:02:17.019: WARN/LockPatternKeyguardView(1059):
LockpatternKeyguardView WallpaperIntentReceiver_getWallpaper start
03-26 05:02:17.019: INFO/ApplicationContext(1059): getWallpaper()
03-26 05:02:17.029: INFO/ApplicationContext(1059): android
03-26 05:02:17.029: INFO/ApplicationContext(1059): GetCurrentWallaper
03-26 05:02:17.029: INFO/ApplicationContext(1059): Normal image
wallpaper
03-26 05:02:17.029: INFO/WallpaperService(1059): List Of Callbacks
03-26 05:02:17.079: ERROR/AndroidRuntime(1694):
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap
android.graphics.bit...@43895170
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.graphics.Canvas.throwIfRecycled(Canvas.java:942)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.graphics.Canvas.drawBitmap(Canvas.java:962)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
com.lge.homecube.Workspace.dispatchDraw(Workspace.java:596)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.drawChild(ViewGroup.java:1484)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
com.lge.homecube.DragLayer.dispatchDraw(DragLayer.java:280)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.drawChild(ViewGroup.java:1484)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.View.draw(View.java:5862)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.drawChild(ViewGroup.java:1486)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.View.draw(View.java:5862)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw
(PhoneWindow.java:1892)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewRoot.draw(ViewRoot.java:1239)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewRoot.performTraversals(ViewRoot.java:1049)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1507)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.os.Looper.loop(Looper.java:123)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
android.app.ActivityThread.main(ActivityThread.java:3948)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
java.lang.reflect.Method.invokeNative(Native Method)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
java.lang.reflect.Method.invoke(Method.java:521)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at
dalvik.system.NativeStart.main(Native Method)
03-26 05:02:17.269: INFO/ApplicationContext(1059): Read wallpaper
file.
03-26 05:02:17.629: INFO/

[android-developers] Re: out of memory error & getWallpaper

2009-08-22 Thread sameer

Hi Nivek,

Can you please tell me the solution for the problem attempt to use
recycled bitmap

Any solution please let me know.

Your reply will be highly appreaciated

Thanks and Regards
Mohammed Sameer

On Aug 17, 11:53 pm, Nivek  wrote:
> When you change the device orientation, you app is closed and then
> reopened.
>
> Android handles bitmaps a "special" way, you HAVE to explicitly
> recycle them as soon as you don't need them anymore... or they stay
> allocated in memory and NEVER get freed.
>
> I have started to code an app which uses a set of ImageViews. To avoid
> allocation errors on orientation changes, I had to override the
> onDestroy() method this way :
>         /*
>          * (non-Javadoc)
>          *
>          * @see android.app.Activity#onDestroy()
>          */
>         @Override
>         protected void onDestroy() {
>                 super.onDestroy();
>                 if (isFinishing()) {
>                         for (ImageView view : mImgViews) {
>                                 Drawable toRecycle = view.getDrawable
> ();
>                                 if (toRecycle != null) {
>                                         ((BitmapDrawable)
> toRecycle).getBitmap().recycle();
>                                 }
>                         }
>                 }
>         }
>
> After this, If the orientation change time is too long, you have to
> store the data (bitmaps and whatever else you need) with
> onRetainNonConfigurationInstance() and get them back on reinit with
> getLastNonConfigurationInstance().
>
> This has been explained by Romain Guy on his blog 
> :http://www.curious-creature.org/2009/02/16/faster-screen-orientation-...
>
> On 17 août, 15:58, Flying Coder  wrote:
>
>
>
> > This has been driving me nuts and I'm hoping someone will be able to
> > help me understand what is happening (or better yet, how to fix
> > it! ;-).
>
> > I set the background image in one of my apps to the system wallpaper
> > image using the following code:
>
> >    Drawable wp = this.getWallpaper();
> >    background = (ImageView) findViewById(R.id.background);
> >    background.setImageDrawable(wp);
>
> > This seems to work fine, but periodically, I get the out of memory
> > error shown below.  Actually, on the emulator, all I have to do is
> > repeatedly rotate the device and this error will consistently happen
> > after 10-12 rotations.  On the G1, opening and closing the keyboard
> > doesn't seem to cause this, but I'll still get the failure every once
> > in a while.
>
> > Is getWallpaper() actually making a copy of the image (I would have
> > thought I'd just get a refernece to the existingbitmap)?  Do I need
> > to do anything special to free the image?
>
> > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> > allocation too large for this process.
> > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> > bytes
> > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> > with uncaught exception (group=0x4000fe70)
> > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> > thread main exiting due to uncaught exception
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> > java.lang.OutOfMemoryError:bitmapsize exceeds VM budget
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> > Method)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> > 424)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.getCurrentWallpaperLocked
> > (ApplicationContext.java:523)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.peekWallpaper(ApplicationContext.java:
> > 515)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.getWallpaper(ApplicationContext.java:
> > 504)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.content.ContextWrapper.getWallpaper(ContextWrapper.java:201)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at onCreate
> > (MyApp.java:247)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> > 1123)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > 2231)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> > 2284)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread.access$1800(ActivityThread.java:112)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> > 08-17 08:32:38.313: ERR

[android-developers] Re: out of memory error & getWallpaper

2009-08-22 Thread sameer

Hi Steve,

PLease let me know how you fixed the belllow exeption
run-time exception the next
attempt to use recycled bitmap.

I m also getting the same exeption
 trying to use a recycled bitmap android.graphics.bit...@43750030


Please reply back. Your reply will be highly appreciated.

Thanks and regards
Mohammed Sameer

On Aug 18, 1:38 am, Flying Coder  wrote:
> Hi Nivek,
>     Unfortunately, doing recycle on the drawable returned by
> ContextWrapper.getWallpaper() results in a run-time exception the next
> time the app is launched:  attempt touserecycledbitmap.  Though
> curiously, if I launch the app again after receiving the exeption, it
> works fine.  I.e., run time exception every other launch.
>
>     At any rate, thanks for the pointer to Romain Guy's blog -- I
> wasn't aware of the onRetainNonConfigurationInstance method.  Should
> be useful in some cases.
>
> Cheers,
> Steve
>
> On Aug 17, 10:53 am, Nivek  wrote:
>
>
>
> > When you change the device orientation, you app is closed and then
> > reopened.
>
> > Android handles bitmaps a "special" way, you HAVE to explicitly
> > recycle them as soon as you don't need them anymore... or they stay
> > allocated in memory and NEVER get freed.
>
> > I have started to code an app which uses a set of ImageViews. To avoid
> > allocation errors on orientation changes, I had to override the
> > onDestroy() method this way :
> >         /*
> >          * (non-Javadoc)
> >          *
> >          * @see android.app.Activity#onDestroy()
> >          */
> >         @Override
> >         protected void onDestroy() {
> >                 super.onDestroy();
> >                 if (isFinishing()) {
> >                         for (ImageView view : mImgViews) {
> >                                 Drawable toRecycle = view.getDrawable
> > ();
> >                                 if (toRecycle != null) {
> >                                         ((BitmapDrawable)
> > toRecycle).getBitmap().recycle();
> >                                 }
> >                         }
> >                 }
> >         }
>
> > After this, If the orientation change time is too long, you have to
> > store the data (bitmaps and whatever else you need) with
> > onRetainNonConfigurationInstance() and get them back on reinit with
> > getLastNonConfigurationInstance().
>
> > This has been explained by Romain Guy on his blog 
> > :http://www.curious-creature.org/2009/02/16/faster-screen-orientation-...
>
> > On 17 août, 15:58, Flying Coder  wrote:
>
> > > This has been driving me nuts and I'm hoping someone will be able to
> > > help me understand what is happening (or better yet, how to fix
> > > it! ;-).
>
> > > I set the background image in one of my apps to the system wallpaper
> > > image using the following code:
>
> > >    Drawable wp = this.getWallpaper();
> > >    background = (ImageView) findViewById(R.id.background);
> > >    background.setImageDrawable(wp);
>
> > > This seems to work fine, but periodically, I get the out of memory
> > > error shown below.  Actually, on the emulator, all I have to do is
> > > repeatedly rotate the device and this error will consistently happen
> > > after 10-12 rotations.  On the G1, opening and closing the keyboard
> > > doesn't seem to cause this, but I'll still get the failure every once
> > > in a while.
>
> > > Is getWallpaper() actually making a copy of the image (I would have
> > > thought I'd just get a refernece to the existingbitmap)?  Do I need
> > > to do anything special to free the image?
>
> > > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> > > allocation too large for this process.
> > > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> > > bytes
> > > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> > > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> > > with uncaught exception (group=0x4000fe70)
> > > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> > > thread main exiting due to uncaught exception
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> > > java.lang.OutOfMemoryError:bitmapsize exceeds VM budget
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> > > Method)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> > > 424)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.app.ApplicationContext.getCurrentWallpaperLocked
> > > (ApplicationContext.java:523)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.app.ApplicationContext.peekWallpaper(ApplicationContext.java:
> > > 515)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.app.ApplicationContext.getWallpaper(ApplicationContext.java:
> > > 504)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > android.content.Con

[android-developers] Re: out of memory error & getWallpaper

2009-08-20 Thread Nivek

Well, even if we should "normally" not call the recycle method, I see
in ApiDemos some calls to this method :
LabelMaker.java - line 281
SpriteTextRenderer.java - line 122
TriangleRenderer.java - line 106

I tried to solve a problem of memory allocation when loading big files
(4000x3000 pics) yesterday and again the manual call to recycle() is
the only working solution I could find to be able to display these
pics one after the other.

Nivek
On 20 août, 16:40, Hong  wrote:
> @Nivek
>
> THANK YOU the recycle() call works GREAT!
> ((BitmapDrawable)d).getBitmap().recycle();
>
> I went through 10~15 photos w/o crashing!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-20 Thread Hong

@Nivek

THANK YOU the recycle() call works GREAT!
((BitmapDrawable)d).getBitmap().recycle();

I went through 10~15 photos w/o crashing!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-20 Thread Hong

Here's the crash log file in case you are interested:

08-20 10:08:00.700: INFO/ActivityManager(18682): Displayed activity
com.android.camera/.ImageGallery2: 1137 ms
08-20 10:08:01.220: VERBOSE/ImageGallery2(20461): /ImageBlockManager.onPause
08-20 10:08:01.280: DEBUG/Main(20546): /sdcard/dcim/Camera/2009-07-27
19.18.31.jpg
08-20 10:08:01.300: ERROR/dalvikvm-heap(20546): 6291456-byte external
allocation too large for this process.
08-20 10:08:01.300: ERROR/(20546): VM won't let us allocate 6291456 bytes
08-20 10:08:01.300: DEBUG/AndroidRuntime(20546): Shutting down VM
08-20 10:08:01.300: WARN/dalvikvm(20546): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
08-20 10:08:01.300: ERROR/AndroidRuntime(20546): Uncaught handler:
thread main exiting due to uncaught exception
08-20 10:08:01.310: ERROR/AndroidRuntime(20546):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget

The picture is something I took with G1 camera, nothing special.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-20 Thread Hong

I'm seeing the same out of memory problem.
It's consistent on my G1 in a few tries.

Basically I used the built-in intent to get the photo on my sdcard,
and set it as the app's background:
Drawable d = Drawable.createFromPath(filename);
mainBg.setBackgroundDrawable(d);

The filename is what passed back from the photo picker in onActivityResult().

Doing this a few times will cause out of memory exception,
reproducible 100% of the time.
If the VM is to *eventually* free up the bitmap object memory, I
suspect it's not doing its job well.

I will give the recyle() a try now, and see if there's any improvement.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Nivek

Ok, so I should replace my calls to ImageView.getDrawable().getBitmap
().recycle() with ImageView.setImageBitmap(null) and let the GC do his
job ?
Or is the call to ImageView.setCallback(null) enough to get rid of
both ImageView and Bitmap instances ?

I'll try to track all my calls to Bitmap.recycle() and better check
where the references to these bitmaps are located.



On 18 août, 00:51, Romain Guy  wrote:
> Bitmap are eventually garbage collected. From the javadoc of the
> Bitmap class itself:
>
> "This is an advanced call, and normally need
> not be called, since the normal GC process will free up this memory when
> there are no more references to this bitmap."
>
>
>
>
>
> On Mon, Aug 17, 2009 at 3:14 PM, Nivek wrote:
>
> > I'm sorry, I've certainly misunderstood something then, but... while
> > coding an app dealing with bitmaps, this is what it looks like.
> > Reading posts and blogs about memory management and use of bitmap led
> > me to that conclusion, and carefully recycling bitmaps in my app
> > allowed me to get rid of a lot of memory allocation exceptions.
>
> > Anyway, about memory leaks on orientation changes, another blog post
> > from Romain Guy could be useful:
> >http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-andr...
>
> > You might try this Drawable.setCallback(null) trick...
>
> > On 17 août, 22:02, Marco Nelissen  wrote:
> >> On Mon, Aug 17, 2009 at 7:53 AM, Nivek wrote:
>
> >> > When you change the device orientation, you app is closed and then
> >> > reopened.
>
> >> > Android handles bitmaps a "special" way, you HAVE to explicitly
> >> > recycle them as soon as you don't need them anymore... or they stay
> >> > allocated in memory and NEVER get freed.
>
> >> That is not true.
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Romain Guy

Bitmap are eventually garbage collected. From the javadoc of the
Bitmap class itself:

"This is an advanced call, and normally need
not be called, since the normal GC process will free up this memory when
there are no more references to this bitmap."

On Mon, Aug 17, 2009 at 3:14 PM, Nivek wrote:
>
> I'm sorry, I've certainly misunderstood something then, but... while
> coding an app dealing with bitmaps, this is what it looks like.
> Reading posts and blogs about memory management and use of bitmap led
> me to that conclusion, and carefully recycling bitmaps in my app
> allowed me to get rid of a lot of memory allocation exceptions.
>
> Anyway, about memory leaks on orientation changes, another blog post
> from Romain Guy could be useful:
> http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/
>
> You might try this Drawable.setCallback(null) trick...
>
>
> On 17 août, 22:02, Marco Nelissen  wrote:
>> On Mon, Aug 17, 2009 at 7:53 AM, Nivek wrote:
>>
>> > When you change the device orientation, you app is closed and then
>> > reopened.
>>
>> > Android handles bitmaps a "special" way, you HAVE to explicitly
>> > recycle them as soon as you don't need them anymore... or they stay
>> > allocated in memory and NEVER get freed.
>>
>> That is not true.
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Nivek

I'm sorry, I've certainly misunderstood something then, but... while
coding an app dealing with bitmaps, this is what it looks like.
Reading posts and blogs about memory management and use of bitmap led
me to that conclusion, and carefully recycling bitmaps in my app
allowed me to get rid of a lot of memory allocation exceptions.

Anyway, about memory leaks on orientation changes, another blog post
from Romain Guy could be useful:
http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/

You might try this Drawable.setCallback(null) trick...


On 17 août, 22:02, Marco Nelissen  wrote:
> On Mon, Aug 17, 2009 at 7:53 AM, Nivek wrote:
>
> > When you change the device orientation, you app is closed and then
> > reopened.
>
> > Android handles bitmaps a "special" way, you HAVE to explicitly
> > recycle them as soon as you don't need them anymore... or they stay
> > allocated in memory and NEVER get freed.
>
> That is not true.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Marco Nelissen

On Mon, Aug 17, 2009 at 7:53 AM, Nivek wrote:
>
> When you change the device orientation, you app is closed and then
> reopened.
>
> Android handles bitmaps a "special" way, you HAVE to explicitly
> recycle them as soon as you don't need them anymore... or they stay
> allocated in memory and NEVER get freed.

That is not true.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Flying Coder


Dianne,
   I suspect you are right, though I'm having a heck of a time
tracking it down (i.e., I don't see any leaks).  Thanks for the info
on the wallpaper!

Cheers,
Steve


On Aug 17, 12:47 pm, Dianne Hackborn  wrote:
> The wallpaper is loaded into each application that requests it.  It is only
> loaded the first time you ask for it, and the next time after it is changed
> to some other image.
>
> You are probably leaking memory.  You can use the hat tool to look at your
> allocations -- search on this list, there have been a number of discussions
> about it.
>
>
>
>
>
> On Mon, Aug 17, 2009 at 9:38 AM, Flying Coder  wrote:
>
> > Hi Nivek,
> >    Unfortunately, doing recycle on the drawable returned by
> > ContextWrapper.getWallpaper() results in a run-time exception the next
> > time the app is launched:  attempt to use recycled bitmap.  Though
> > curiously, if I launch the app again after receiving the exeption, it
> > works fine.  I.e., run time exception every other launch.
>
> >    At any rate, thanks for the pointer to Romain Guy's blog -- I
> > wasn't aware of the onRetainNonConfigurationInstance method.  Should
> > be useful in some cases.
>
> > Cheers,
> > Steve
>
> > On Aug 17, 10:53 am, Nivek  wrote:
> > > When you change the device orientation, you app is closed and then
> > > reopened.
>
> > > Android handles bitmaps a "special" way, you HAVE to explicitly
> > > recycle them as soon as you don't need them anymore... or they stay
> > > allocated in memory and NEVER get freed.
>
> > > I have started to code an app which uses a set of ImageViews. To avoid
> > > allocation errors on orientation changes, I had to override the
> > > onDestroy() method this way :
> > >         /*
> > >          * (non-Javadoc)
> > >          *
> > >          * @see android.app.Activity#onDestroy()
> > >          */
> > >         @Override
> > >         protected void onDestroy() {
> > >                 super.onDestroy();
> > >                 if (isFinishing()) {
> > >                         for (ImageView view : mImgViews) {
> > >                                 Drawable toRecycle = view.getDrawable
> > > ();
> > >                                 if (toRecycle != null) {
> > >                                         ((BitmapDrawable)
> > > toRecycle).getBitmap().recycle();
> > >                                 }
> > >                         }
> > >                 }
> > >         }
>
> > > After this, If the orientation change time is too long, you have to
> > > store the data (bitmaps and whatever else you need) with
> > > onRetainNonConfigurationInstance() and get them back on reinit with
> > > getLastNonConfigurationInstance().
>
> > > This has been explained by Romain Guy on his blog :
> >http://www.curious-creature.org/2009/02/16/faster-screen-orientation-...
>
> > > On 17 août, 15:58, Flying Coder  wrote:
>
> > > > This has been driving me nuts and I'm hoping someone will be able to
> > > > help me understand what is happening (or better yet, how to fix
> > > > it! ;-).
>
> > > > I set the background image in one of my apps to the system wallpaper
> > > > image using the following code:
>
> > > >    Drawable wp = this.getWallpaper();
> > > >    background = (ImageView) findViewById(R.id.background);
> > > >    background.setImageDrawable(wp);
>
> > > > This seems to work fine, but periodically, I get the out of memory
> > > > error shown below.  Actually, on the emulator, all I have to do is
> > > > repeatedly rotate the device and this error will consistently happen
> > > > after 10-12 rotations.  On the G1, opening and closing the keyboard
> > > > doesn't seem to cause this, but I'll still get the failure every once
> > > > in a while.
>
> > > > Is getWallpaper() actually making a copy of the image (I would have
> > > > thought I'd just get a refernece to the existing bitmap)?  Do I need
> > > > to do anything special to free the image?
>
> > > > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> > > > allocation too large for this process.
> > > > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> > > > bytes
> > > > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> > > > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> > > > with uncaught exception (group=0x4000fe70)
> > > > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> > > > thread main exiting due to uncaught exception
> > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> > > > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> > > > Method)
> > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> > > > 424)
> > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > > > android.app.ApplicationContext.getCurrentWa

[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Dianne Hackborn
The wallpaper is loaded into each application that requests it.  It is only
loaded the first time you ask for it, and the next time after it is changed
to some other image.

You are probably leaking memory.  You can use the hat tool to look at your
allocations -- search on this list, there have been a number of discussions
about it.

On Mon, Aug 17, 2009 at 9:38 AM, Flying Coder  wrote:

>
> Hi Nivek,
>Unfortunately, doing recycle on the drawable returned by
> ContextWrapper.getWallpaper() results in a run-time exception the next
> time the app is launched:  attempt to use recycled bitmap.  Though
> curiously, if I launch the app again after receiving the exeption, it
> works fine.  I.e., run time exception every other launch.
>
>At any rate, thanks for the pointer to Romain Guy's blog -- I
> wasn't aware of the onRetainNonConfigurationInstance method.  Should
> be useful in some cases.
>
> Cheers,
> Steve
>
>
> On Aug 17, 10:53 am, Nivek  wrote:
> > When you change the device orientation, you app is closed and then
> > reopened.
> >
> > Android handles bitmaps a "special" way, you HAVE to explicitly
> > recycle them as soon as you don't need them anymore... or they stay
> > allocated in memory and NEVER get freed.
> >
> > I have started to code an app which uses a set of ImageViews. To avoid
> > allocation errors on orientation changes, I had to override the
> > onDestroy() method this way :
> > /*
> >  * (non-Javadoc)
> >  *
> >  * @see android.app.Activity#onDestroy()
> >  */
> > @Override
> > protected void onDestroy() {
> > super.onDestroy();
> > if (isFinishing()) {
> > for (ImageView view : mImgViews) {
> > Drawable toRecycle = view.getDrawable
> > ();
> > if (toRecycle != null) {
> > ((BitmapDrawable)
> > toRecycle).getBitmap().recycle();
> > }
> > }
> > }
> > }
> >
> > After this, If the orientation change time is too long, you have to
> > store the data (bitmaps and whatever else you need) with
> > onRetainNonConfigurationInstance() and get them back on reinit with
> > getLastNonConfigurationInstance().
> >
> > This has been explained by Romain Guy on his blog :
> http://www.curious-creature.org/2009/02/16/faster-screen-orientation-...
> >
> > On 17 août, 15:58, Flying Coder  wrote:
> >
> >
> >
> > > This has been driving me nuts and I'm hoping someone will be able to
> > > help me understand what is happening (or better yet, how to fix
> > > it! ;-).
> >
> > > I set the background image in one of my apps to the system wallpaper
> > > image using the following code:
> >
> > >Drawable wp = this.getWallpaper();
> > >background = (ImageView) findViewById(R.id.background);
> > >background.setImageDrawable(wp);
> >
> > > This seems to work fine, but periodically, I get the out of memory
> > > error shown below.  Actually, on the emulator, all I have to do is
> > > repeatedly rotate the device and this error will consistently happen
> > > after 10-12 rotations.  On the G1, opening and closing the keyboard
> > > doesn't seem to cause this, but I'll still get the failure every once
> > > in a while.
> >
> > > Is getWallpaper() actually making a copy of the image (I would have
> > > thought I'd just get a refernece to the existing bitmap)?  Do I need
> > > to do anything special to free the image?
> >
> > > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> > > allocation too large for this process.
> > > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> > > bytes
> > > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> > > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> > > with uncaught exception (group=0x4000fe70)
> > > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> > > thread main exiting due to uncaught exception
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> > > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at
> > > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> > > Method)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at
> > > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> > > 424)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at
> > > android.app.ApplicationContext.getCurrentWallpaperLocked
> > > (ApplicationContext.java:523)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at
> > > android.app.ApplicationContext.peekWallpaper(ApplicationContext.java:
> > > 515)
> > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at
> > > android.app.ApplicationContext.getWallpaper(ApplicationContext.java:
> > > 504)
> > > 08-17 08:32:38.313: ERROR

[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Flying Coder

Hi Nivek,
Unfortunately, doing recycle on the drawable returned by
ContextWrapper.getWallpaper() results in a run-time exception the next
time the app is launched:  attempt to use recycled bitmap.  Though
curiously, if I launch the app again after receiving the exeption, it
works fine.  I.e., run time exception every other launch.

At any rate, thanks for the pointer to Romain Guy's blog -- I
wasn't aware of the onRetainNonConfigurationInstance method.  Should
be useful in some cases.

Cheers,
Steve


On Aug 17, 10:53 am, Nivek  wrote:
> When you change the device orientation, you app is closed and then
> reopened.
>
> Android handles bitmaps a "special" way, you HAVE to explicitly
> recycle them as soon as you don't need them anymore... or they stay
> allocated in memory and NEVER get freed.
>
> I have started to code an app which uses a set of ImageViews. To avoid
> allocation errors on orientation changes, I had to override the
> onDestroy() method this way :
>         /*
>          * (non-Javadoc)
>          *
>          * @see android.app.Activity#onDestroy()
>          */
>         @Override
>         protected void onDestroy() {
>                 super.onDestroy();
>                 if (isFinishing()) {
>                         for (ImageView view : mImgViews) {
>                                 Drawable toRecycle = view.getDrawable
> ();
>                                 if (toRecycle != null) {
>                                         ((BitmapDrawable)
> toRecycle).getBitmap().recycle();
>                                 }
>                         }
>                 }
>         }
>
> After this, If the orientation change time is too long, you have to
> store the data (bitmaps and whatever else you need) with
> onRetainNonConfigurationInstance() and get them back on reinit with
> getLastNonConfigurationInstance().
>
> This has been explained by Romain Guy on his blog 
> :http://www.curious-creature.org/2009/02/16/faster-screen-orientation-...
>
> On 17 août, 15:58, Flying Coder  wrote:
>
>
>
> > This has been driving me nuts and I'm hoping someone will be able to
> > help me understand what is happening (or better yet, how to fix
> > it! ;-).
>
> > I set the background image in one of my apps to the system wallpaper
> > image using the following code:
>
> >    Drawable wp = this.getWallpaper();
> >    background = (ImageView) findViewById(R.id.background);
> >    background.setImageDrawable(wp);
>
> > This seems to work fine, but periodically, I get the out of memory
> > error shown below.  Actually, on the emulator, all I have to do is
> > repeatedly rotate the device and this error will consistently happen
> > after 10-12 rotations.  On the G1, opening and closing the keyboard
> > doesn't seem to cause this, but I'll still get the failure every once
> > in a while.
>
> > Is getWallpaper() actually making a copy of the image (I would have
> > thought I'd just get a refernece to the existing bitmap)?  Do I need
> > to do anything special to free the image?
>
> > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> > allocation too large for this process.
> > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> > bytes
> > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> > with uncaught exception (group=0x4000fe70)
> > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> > thread main exiting due to uncaught exception
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> > Method)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> > 424)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.getCurrentWallpaperLocked
> > (ApplicationContext.java:523)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.peekWallpaper(ApplicationContext.java:
> > 515)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ApplicationContext.getWallpaper(ApplicationContext.java:
> > 504)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.content.ContextWrapper.getWallpaper(ContextWrapper.java:201)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at onCreate
> > (MyApp.java:247)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> > 1123)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > 2231)
> > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> > android.app.ActivityThread.handleLaunchActivity(Acti

[android-developers] Re: out of memory error & getWallpaper

2009-08-17 Thread Nivek

When you change the device orientation, you app is closed and then
reopened.

Android handles bitmaps a "special" way, you HAVE to explicitly
recycle them as soon as you don't need them anymore... or they stay
allocated in memory and NEVER get freed.

I have started to code an app which uses a set of ImageViews. To avoid
allocation errors on orientation changes, I had to override the
onDestroy() method this way :
/*
 * (non-Javadoc)
 *
 * @see android.app.Activity#onDestroy()
 */
@Override
protected void onDestroy() {
super.onDestroy();
if (isFinishing()) {
for (ImageView view : mImgViews) {
Drawable toRecycle = view.getDrawable
();
if (toRecycle != null) {
((BitmapDrawable)
toRecycle).getBitmap().recycle();
}
}
}
}

After this, If the orientation change time is too long, you have to
store the data (bitmaps and whatever else you need) with
onRetainNonConfigurationInstance() and get them back on reinit with
getLastNonConfigurationInstance().

This has been explained by Romain Guy on his blog :
http://www.curious-creature.org/2009/02/16/faster-screen-orientation-change-with-android/




On 17 août, 15:58, Flying Coder  wrote:
> This has been driving me nuts and I'm hoping someone will be able to
> help me understand what is happening (or better yet, how to fix
> it! ;-).
>
> I set the background image in one of my apps to the system wallpaper
> image using the following code:
>
>    Drawable wp = this.getWallpaper();
>    background = (ImageView) findViewById(R.id.background);
>    background.setImageDrawable(wp);
>
> This seems to work fine, but periodically, I get the out of memory
> error shown below.  Actually, on the emulator, all I have to do is
> repeatedly rotate the device and this error will consistently happen
> after 10-12 rotations.  On the G1, opening and closing the keyboard
> doesn't seem to cause this, but I'll still get the failure every once
> in a while.
>
> Is getWallpaper() actually making a copy of the image (I would have
> thought I'd just get a refernece to the existing bitmap)?  Do I need
> to do anything special to free the image?
>
> 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external
> allocation too large for this process.
> 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400
> bytes
> 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM
> 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting
> with uncaught exception (group=0x4000fe70)
> 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler:
> thread main exiting due to uncaught exception
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):
> java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native
> Method)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:
> 424)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ApplicationContext.getCurrentWallpaperLocked
> (ApplicationContext.java:523)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ApplicationContext.peekWallpaper(ApplicationContext.java:
> 515)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ApplicationContext.getWallpaper(ApplicationContext.java:
> 504)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.content.ContextWrapper.getWallpaper(ContextWrapper.java:201)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at onCreate
> (MyApp.java:247)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1123)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2231)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2284)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ActivityThread.access$1800(ActivityThread.java:112)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.os.Looper.loop(Looper.java:123)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> android.app.ActivityThread.main(ActivityThread.java:3948)
> 08-17 08:32:38.313: ERROR/AndroidRuntime(1597):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 08

[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread guruk

:) ok.. thats quit a lot of new ideas i can play with
keep your good vibes and thanks again
chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread Streets Of Boston

I don't know the answer to all your questions in your previous post,
but this is a trick i used to get a 'circular' list-view (not a
gallery, but i think they are comparable).

I needed a list-view that is circular, i.e. after the last element the
first element appears again.

I attached a ListAdapter (BaseAdapter) to my list-view and overrode
the methods of BaseAdapter.
- No scrollbar
- I overrode getCount() to return a large value (e.g. 100)
- I override getItem(int pos) to return the correct element from my
array (use modulo operator, because pos can have a value of 99,
getCount()-1).
- Override any method in Adapter that takes a position as input. Use
the module operator to figure the actual index into your array of data
(bitmaps).


On May 22, 9:33 am, guruk  wrote:
> thanks for your help, i will give it a try.
>
> ... also when I have a bphotoList (an array of bitmaps)
> and I reload this Array with new Bitmaps, what do I have to do that
> they gallery
> use them. I thought it come automaticly, because I just change the
> content, but
> it looks the gallery cache the old content somewhere?
>
> And to make it round. lets say i have a gallery with 10pics, while at
> pic 10
> (simple version) i change the content of the PhotoArray.. how can i
> let
> jump the gallery to position 1? (and for sure show the new content and
> not something cached:)
>
> thanks chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread guruk

thanks for your help, i will give it a try.

... also when I have a bphotoList (an array of bitmaps)
and I reload this Array with new Bitmaps, what do I have to do that
they gallery
use them. I thought it come automaticly, because I just change the
content, but
it looks the gallery cache the old content somewhere?

And to make it round. lets say i have a gallery with 10pics, while at
pic 10
(simple version) i change the content of the PhotoArray.. how can i
let
jump the gallery to position 1? (and for sure show the new content and
not something cached:)

thanks chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread Streets Of Boston

... // determine the width/height or a gallery item's view
Rect rectOfGalleryItemView = ...;
...
... // Then determine the best sampleSize (1, 2, 4, 8)
int sampleSize = calculateSampleSize(rectOfGalleryItemView, 2048,
1536);

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inDither = true; // we're using RGB_565, dithering improves this
a bit.
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inSampleSize = sampleSize;
bm = BitmapFactory.decodeStream("/sdcard/dcim/Camera/" + photoList[i],
opts);

And yes, it takes a bit longer to decode here. In my app, i put
decoding the bitmap in a background thread (much like AsyncTask). But
you can cache the decoded bitmaps and be a bit smart about pre-loading
bitmaps before they become visible in the Gallery. If you use a cache,
you need to manage the cache. Clear it when memory may run low, etc.

On another note; i noticed that using an inSampleSize value of larger
than 1 produces better quality images than using createScaledBitmap.



On May 22, 9:12 am, guruk  wrote:
> :) I got it now already up to 15 :)
>
> bm = BitmapFactory.decodeFile("/sdcard/dcim/Camera/" + photoList[i]);
> bphotos.add(Bitmap.createScaledBitmap(bm, 480, 320, true));
> bm.recycle();
>
> when I always use bm.recycle()
>
> ok, but lets look on your insamplesize... i will also try.
> but how to use in samplzesiez with decodeFile?
> finaly i need 480x320...
>
> but i am not sure if that helps at all. because life decoding needs
> quit long time. so i have 2 options. a thread with background decoding
> or creating thumbs and loading them direct into a gallery
>
> but please tell me how to use insamplesize with .decodeFile or
> creatscalebitmap
>
> greets
> chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread guruk

:) I got it now already up to 15 :)

bm = BitmapFactory.decodeFile("/sdcard/dcim/Camera/" + photoList[i]);
bphotos.add(Bitmap.createScaledBitmap(bm, 480, 320, true));
bm.recycle();

when I always use bm.recycle()

ok, but lets look on your insamplesize... i will also try.
but how to use in samplzesiez with decodeFile?
finaly i need 480x320...

but i am not sure if that helps at all. because life decoding needs
quit long time. so i have 2 options. a thread with background decoding
or creating thumbs and loading them direct into a gallery

but please tell me how to use insamplesize with .decodeFile or
creatscalebitmap

greets
chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of Memory Error in BitmapFactory.decodeFile

2009-05-22 Thread Streets Of Boston

I'm amazed yout get it working 2 times. :=)

You can not load so many (3 or more) big (over 3Mpixels) in one
process. You'll run out of memory. A full size pic of 3Mpixels in
RGB_565(16bit color) is 6MBytes of memory.

You have to decode the file with the Option's 'inSampleSize' set to
something larger than 1. 1 --> decode full size; 2 --> decode quarter
size; 4 --> decode 1/16th size. E.g. when set to 2, you'll get a
1024x786 sized pic, a quarter of the original size.

You should choose a inSampleSize that will produce a bitmap that is
closest to your view's size, so that you don't waste pixels that will
never be displayed anyway and that you don't 'waste' memory.

On May 22, 7:17 am, guruk  wrote:
> Hi,
> I was reading in some other posts that some developers have the same
> Problem, but till now, no solution.
> its about the gallery: I have a string array with photos, but when the
> gallery does show the 2nd Picture it
> crash with:
>
> ---
> D/votw    (18078):  --- DebugMark 1    E/dalvikvm-heap(18078):
> 6291456-byte external allocation too large for this process.
> E/        (18078): VM won't let us allocate 6291456 bytes /skia
> 
>
> bm= BitmapFactory.decodeFile("/sdcard/dcim/Camera/" + photoList[0]);
>
> -- It works fine 2 Times, starting with the 3rd Time it crash.
> - In other Threads they adviced to use another pic, but as you see I
> try now
>    with (photoList[0]) so its a FIXED same Picture.
>
> So I guess I have to release somehow the Memory, but how?
>
> Thanks
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of memory error in frame animation

2009-03-22 Thread Romain Guy

No it won't reduce the memory usage, at least not if the png don't
have an alpha channel.

On Sun, Mar 22, 2009 at 10:59 PM, iDeveloper  wrote:
>
> Try using jpegs instead of pngs. That'll reduce your memory usage
> quite a bit if you have to use these images and alpha is not a concern.
>
>
>
> On 23-Mar-09, at 11:22 AM, Romain Guy wrote:
>
>>
>> There's no other way, you are using too much memory, that's all. Note
>> that you might have a memory leak somewhere though.
>>
>> On Sun, Mar 22, 2009 at 10:51 PM, Archana 
>> wrote:
>>>
>>> Thanks for the reply,but i have to use that much png files in my app
>>> without that it wont look nice.
>>> can you please suggest me some other way.
>>>
>>> On Mar 23, 10:35 am, Romain Guy  wrote:
 Use less memory in your app.

 On Sun, Mar 22, 2009 at 10:23 PM, Archana >>> 14n...@gmail.com> wrote:

> Hi,

>  I am using frame animation in multiple page where in each page i
> am
> using set of png files. First animation is

> working fine but when i am trying to call second animation it
> showing

> java.lang.OutOfMemoryError: bitmap size exceeds VM budget

> Is there any way to solve this issue.Please help its very urgent.

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have
 time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

>>>
>>
>>
>>
>> --
>> Romain Guy
>> Android framework engineer
>> romain...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support.  All such questions should be posted on
>> public forums, where I and others can see and answer them
>>
>> >
>
>
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of memory error in frame animation

2009-03-22 Thread iDeveloper

Try using jpegs instead of pngs. That'll reduce your memory usage  
quite a bit if you have to use these images and alpha is not a concern.



On 23-Mar-09, at 11:22 AM, Romain Guy wrote:

>
> There's no other way, you are using too much memory, that's all. Note
> that you might have a memory leak somewhere though.
>
> On Sun, Mar 22, 2009 at 10:51 PM, Archana   
> wrote:
>>
>> Thanks for the reply,but i have to use that much png files in my app
>> without that it wont look nice.
>> can you please suggest me some other way.
>>
>> On Mar 23, 10:35 am, Romain Guy  wrote:
>>> Use less memory in your app.
>>>
>>> On Sun, Mar 22, 2009 at 10:23 PM, Archana >> 14n...@gmail.com> wrote:
>>>
 Hi,
>>>
  I am using frame animation in multiple page where in each page i  
 am
 using set of png files. First animation is
>>>
 working fine but when i am trying to call second animation it  
 showing
>>>
 java.lang.OutOfMemoryError: bitmap size exceeds VM budget
>>>
 Is there any way to solve this issue.Please help its very urgent.
>>>
>>> --
>>> Romain Guy
>>> Android framework engineer
>>> romain...@android.com
>>>
>>> Note: please don't send private questions to me, as I don't have  
>>> time
>>> to provide private support.  All such questions should be posted on
>>> public forums, where I and others can see and answer them
>>>
>>
>
>
>
> -- 
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of memory error in frame animation

2009-03-22 Thread Romain Guy

There's no other way, you are using too much memory, that's all. Note
that you might have a memory leak somewhere though.

On Sun, Mar 22, 2009 at 10:51 PM, Archana  wrote:
>
> Thanks for the reply,but i have to use that much png files in my app
> without that it wont look nice.
> can you please suggest me some other way.
>
> On Mar 23, 10:35 am, Romain Guy  wrote:
>> Use less memory in your app.
>>
>> On Sun, Mar 22, 2009 at 10:23 PM, Archana  wrote:
>>
>> > Hi,
>>
>> >  I am using frame animation in multiple page where in each page i am
>> > using set of png files. First animation is
>>
>> > working fine but when i am trying to call second animation it showing
>>
>> > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
>>
>> > Is there any way to solve this issue.Please help its very urgent.
>>
>> --
>> Romain Guy
>> Android framework engineer
>> romain...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support.  All such questions should be posted on
>> public forums, where I and others can see and answer them
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of memory error in frame animation

2009-03-22 Thread Archana

Thanks for the reply,but i have to use that much png files in my app
without that it wont look nice.
can you please suggest me some other way.

On Mar 23, 10:35 am, Romain Guy  wrote:
> Use less memory in your app.
>
> On Sun, Mar 22, 2009 at 10:23 PM, Archana  wrote:
>
> > Hi,
>
> >  I am using frame animation in multiple page where in each page i am
> > using set of png files. First animation is
>
> > working fine but when i am trying to call second animation it showing
>
> > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
>
> > Is there any way to solve this issue.Please help its very urgent.
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Out of memory error in frame animation

2009-03-22 Thread Romain Guy

Use less memory in your app.

On Sun, Mar 22, 2009 at 10:23 PM, Archana  wrote:
>
> Hi,
>
>  I am using frame animation in multiple page where in each page i am
> using set of png files. First animation is
>
> working fine but when i am trying to call second animation it showing
>
> java.lang.OutOfMemoryError: bitmap size exceeds VM budget
>
> Is there any way to solve this issue.Please help its very urgent.
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---