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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:48:39+00:00 2026-06-06T10:48:39+00:00

I have in my application many bitmaps. They are loaded when application start. In

  • 0

I have in my application many bitmaps. They are loaded when application start. In one activity I have a two buttons where I change language, but when I click on button I start loading images again. Sometimes I get error with out of memory. How I can clean memory, that when I click on button I clean memory and after that loading bitmaps? This is possible to do? Now I use system.exit(0) but I don’t want close all application.

  • 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-06T10:48:41+00:00Added an answer on June 6, 2026 at 10:48 am

    I was facing the same issue with a graphics-processing intensive app a while ago and after lots of debugging I figured out that Bitmap objects are not properly freed automatically.

    You should manage Bitmaps on your own by calling their recycle method as soon as you don’t need them anymore (Activity.onStop method for example).

    EDIT (10/08/2014):

    The Android developer documentation finally contains clear explanations for these bitmap memory problems. Some things have changed in the meanwhile for the better, but we typically still have to deal with older Android versions that make bitmap memory management difficult.

    Here are the key points:

    As of Android 2.3.3 (API level 10) and lower

    • pixel data is stored in native memory…
    • …and not in the Dalvik heap memory
    • pixel data is released in an unpredictable way

    The problem shows up when you already depleted the Dalvik heap memory limit with bitmaps (or other big objects) and try to load another bitmap. Even if you do not hold any references anymore on older bitmap objects, it is not guaranteed that those bitmaps get garbage collected before a new bitmap object is allocated. Therefore you can randomly hit the limit and get an OutOfMemoryError.

    It is therefore important to manage bitmap objects yourself. When you are done with using a bitmap you should call its recycle() method before loading another bitmap.

    Since Android 3.0 (API level 11)

    • pixel data is stored on Dalvik heap together with the bitmap object

    Here Dalvik’s memory manager can see how much memory is left and has full control over reclaiming memory.

    Managing Bitmaps

    In both cases (older Android versions and newer) you may want to manage your bitmap objects in order to avoid:

    • Repeated loading of the same image (optimization issue)
    • Running out of memory (stability issue)

    The Android developer documentation contains detailed information about how to cache and reuse already loaded bitmap objects using a least-recently-used cache (LruCache).

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

Sidebar

Related Questions

A small - little question. I have seen many application having buttons like following.
I have an application which has many services and one UI module. All these
i have many application running on my emulator but ps -ef does not show
I use c# and c++ builder, and have big application with many menus, buttons,
I have an application which has many icons (Buttons). I want to put a
I have throughout my application many methods where I load collections. They all (actually
I have an application with many different parts, it runs on OSGi, so there's
I have an application with many views. I want only a couple of the
I'm using JSF 1.2 with Richfaces and Facelets. I have an application with many
I have an application that writes many times to a formula/macro-laden workbook. It loops

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.