Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9172247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:17:59+00:00 2026-06-17T16:17:59+00:00

I am tired of trying every possibility in stackoverflow and googled alot…… not getting

  • 0

I am tired of trying every possibility in stackoverflow and googled alot……
not getting what i want.

bt=BitmapFactory.decodeResource(getResources(), dressarray[indexdress],options);
//Background1 = getApplicationContext().getResources().getDrawable(dressarray[indexdress]);
bt1=Bitmap.createBitmap(bt);
dress.setImageBitmap(bt1);

i have this code in various if else conditions… dress in code is ImageView
there are lots of images on my screen..
there are 10 ImageButtons and for those i have 1 onClick method which performs above operation on particular ImageView by checking which button is pressed.

at last i call a method to recycle bitmap(which is my last variation before asking question) inside onClick.
call to that method is the last line in onClick

here is the method to recycle

public void callrecycle()
    {
        bt.recycle();
        bt=null;
        bt1=null;
        System.gc();
    }

now problem is i hav an emulator with HTC EVO screen density and resolution with platform 2.3.3 an a second emulator with density 180 resolution 320X480 and platform 2.2

on 2.3.3 i get an error

07-06 10:42:41.898: D/dalvikvm(420): GC_EXTERNAL_ALLOC freed <1K, 52% free 2611K/5379K, external 19034K/19732K, paused 55ms
07-06 10:42:41.918: E/dalvikvm-heap(420): 1382400-byte external allocation too large for this process.
07-06 10:42:42.028: I/dalvikvm-heap(420): Clamp target GC heap from 25.682MB to 24.000MB
07-06 10:42:42.028: E/GraphicsJNI(420): VM won't let us allocate 1382400 bytes
07-06 10:42:42.028: D/dalvikvm(420): GC_FOR_MALLOC freed <1K, 52% free 2611K/5379K, external 19034K/19732K, paused 35ms
07-06 10:42:42.028: D/AndroidRuntime(420): Shutting down VM
07-06 10:42:42.028: W/dalvikvm(420): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-06 10:42:42.050: E/AndroidRuntime(420): FATAL EXCEPTION: main
07-06 10:42:42.050: E/AndroidRuntime(420): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.graphics.Bitmap.nativeCreate(Native Method)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.graphics.Bitmap.createBitmap(Bitmap.java:432)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.graphics.Bitmap.createBitmap(Bitmap.java:383)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.graphics.Bitmap.createBitmap(Bitmap.java:367)
07-06 10:42:42.050: E/AndroidRuntime(420):  at com.internetdesignzone.dressup.DressUp$1.onClick(DressUp.java:334)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.view.View.performClick(View.java:2485)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.view.View$PerformClick.run(View.java:9080)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.os.Handler.handleCallback(Handler.java:587)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.os.Looper.loop(Looper.java:123)
07-06 10:42:42.050: E/AndroidRuntime(420):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-06 10:42:42.050: E/AndroidRuntime(420):  at java.lang.reflect.Method.invokeNative(Native Method)
07-06 10:42:42.050: E/AndroidRuntime(420):  at java.lang.reflect.Method.invoke(Method.java:507)
07-06 10:42:42.050: E/AndroidRuntime(420):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-06 10:42:42.050: E/AndroidRuntime(420):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-06 10:42:42.050: E/AndroidRuntime(420):  at dalvik.system.NativeStart.main(Native Method)
07-06 10:42:44.968: I/Process(420): Sending signal. PID: 420 SIG: 9

and on 2.2 aget an error with same piece of code

07-06 10:35:37.929: D/dalvikvm(351): GC_EXTERNAL_ALLOC freed 3K, 52% free 2620K/5379K, external 6273K/7166K, paused 59ms
07-06 10:35:38.249: D/AndroidRuntime(351): Shutting down VM
07-06 10:35:38.271: W/dalvikvm(351): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-06 10:35:38.329: E/AndroidRuntime(351): FATAL EXCEPTION: main
07-06 10:35:38.329: E/AndroidRuntime(351): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@4051e4c8
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.graphics.Canvas.throwIfRecycled(Canvas.java:955)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.graphics.Canvas.drawBitmap(Canvas.java:1044)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:325)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.widget.ImageView.onDraw(ImageView.java:854)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.View.draw(View.java:6880)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.View.draw(View.java:6883)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.View.draw(View.java:6883)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.widget.FrameLayout.draw(FrameLayout.java:357)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.View.draw(View.java:6883)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.widget.FrameLayout.draw(FrameLayout.java:357)
07-06 10:35:38.329: E/AndroidRuntime(351):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewRoot.draw(ViewRoot.java:1522)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.os.Looper.loop(Looper.java:123)
07-06 10:35:38.329: E/AndroidRuntime(351):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-06 10:35:38.329: E/AndroidRuntime(351):  at java.lang.reflect.Method.invokeNative(Native Method)
07-06 10:35:38.329: E/AndroidRuntime(351):  at java.lang.reflect.Method.invoke(Method.java:507)
07-06 10:35:38.329: E/AndroidRuntime(351):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-06 10:35:38.329: E/AndroidRuntime(351):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-06 10:35:38.329: E/AndroidRuntime(351):  at dalvik.system.NativeStart.main(Native Method)
07-06 10:35:40.789: I/Process(351): Sending signal. PID: 351 SIG: 9

can anybody tell me the reason?
and please tell me how can i reuse recycled bitmap.
i don want to reduce the quality of bitmap.

the options i am passing have

inPurgeable=true
inInputShareable=true

Note: if i dont use Bitmap thing and directly write dress.setImageResource(dressarray[indexdress]);

the app works like a champ in 2.2 but closes with Out Of Budget on 1st click on 2.3.3
and dressarray[indexdress] is an array of images containing R.drawble.imgid and all are PNG images

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:18:00+00:00Added an answer on June 17, 2026 at 4:18 pm

    I solved this issue at that time by using downgraded images.

    You can avoid this error by using inSampleSize & inPurgeable in options.
    and reusing the same Bitmap variable and making it null after every use.

    call System.gc() wherever possible. it doesn’t call gc but gives hit that it can be started.

    inPurgeable will make ur bitmap object cleanable while doing gc().

    inSampleSize will downgrade bitmap so use a proper value.

    also you can resize your bitmap while creating so that it can reduce its size. use createScaledBitmap()

    Hope it help others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the timed_wait from boost. Now I am actually not
I am trying to renaming every file's empty space with an underscore: DirectoryInfo dir
I am trying to download page_source to a file. However, every time I get
Im tired of trying to put this working :( So, here is my problem:
I'm trying to replace every image tag in a block of text with a
I'm trying to use the select function to accept input but every 2 seconds
I am trying to present a view controller (a passcode request type view) every
I am trying to display the URL of an Image after every image in
I am trying to run following HTML in every browser: Opera, FF, IE, Chrome
I am trying to implement some jQuery into my asp project and every time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.