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 8564187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:08:20+00:00 2026-06-11T17:08:20+00:00

This question is related with Do we have to explicitly recycle the bitmap if

  • 0

This question is related with Do we have to explicitly recycle the bitmap if we don't need it?.

There is an ImageView have a drawable, when user clicks a button, it will assign a new drawable to the ImageView.

Do we have to destroy the old drawable belongs to the ImageView, and how?

Drawable oriDrawable = imageView.getDrawable()

// set callback to null
oriDrawable.setCallback(null);

// get the bitmap and recycle it
((BitmapDrawable)oriDrawable).getBitmap().recycle();

Is the code above correct? What’s the best solution?

  • 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-11T17:08:22+00:00Added an answer on June 11, 2026 at 5:08 pm

    Is this just a general question or are you running out of memory? I would not make this optimisation until you really have a problem.

    In general if you are loading bitmaps from drawable folders that are not large (large as in megabytes) then you should not really run into a problem.

    First you need to make sure the assets you are loading are optimal for where you display them, for example there is no point in setting an ImageView to an image thats 1024 x 1024 in size if the area you display the image is a size of 64×64.

    Breaking the bitmap budget is usually caused by loading in images of an unknown size or just simply getting the image sizes wrong as described above, swapping an ImageView frequently will generally not give you an issue with optimal sized images.

    There is a great article in Android Training that covers loading bitmaps optimally http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

    Hope that helps

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

Sidebar

Related Questions

I have a question related to this one . I don't want to do
This question is related to database/RDBMS where i have little knowledge regarding performance and
This question is related to awk, I suppose. I have no experience with awk.
This question is related to another question I asked Basically, I have 2 horizontally
This question is related to my previous question . The storyline: I have an
This question is related to a WPF application. I have a class as below
I have searched here, GooBingHooVista'd the world and read this related question for VS
Another question related to this one . I have a List<SortableObjects> that is the
This question is kind of related to another question but I have a specific
I have a question related to this one : I'm trying to attach an

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.