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

  • Home
  • SEARCH
  • 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 8728659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:41:26+00:00 2026-06-13T08:41:26+00:00

I have a basic activity (SherlockActivity subclass), and the view it loads has a

  • 0

I have a basic activity (SherlockActivity subclass), and the view it loads has a single, max-sized ImageView.

<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
    p1:orientation="vertical"
    p1:minWidth="25px"
    p1:minHeight="25px"
    p1:layout_width="fill_parent"
    p1:layout_height="fill_parent"
    p1:id="@+id/linearLayout1">
    <ImageView
        p1:src="@android:drawable/ic_menu_gallery"
        p1:layout_width="fill_parent"
        p1:layout_height="fill_parent"
        p1:id="@+id/imageView"
        p1:scaleType="fitCenter" />
</LinearLayout>

The only thing the Activity does is load a Bitmap and assign it to the ImageView

var iv = FindViewById<ImageView>(Resource.Id.imageView);
iv.SetBitmapImage(BitmapFactory.decodeFile(file....))

Before I worked out how to resize bitmaps on load ( http://developer.android.com/training/displaying-bitmaps/load-bitmap.html ) this was chewing up 5MB of memory each time I loaded the activity, until the app crashed (now it doesn’t, but I think this problem is still there). Even if I did it like this:

  • In parent activity, tap button to open child
  • In child (the above image view) tap back
  • In parent, open child
  • In child, tap back
  • etc etc. until it crashes (about 4 times around, as it’s 5MB each time!)

SO THE ACTUAL QUESTION: Am I expected to dispose of the image when the Activity stops or is destroyed? I thought in Java – or C# – things are GC’ed, so I don’t need to do it. Am I missing something in the Activity lifecycle?

Both answer authors eventually came up with the right answer (the GC does it, but you can force it with recycle(). So marking correct the one which had it in the answer, so it’s easier to find for others

  • 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-13T08:41:27+00:00Added an answer on June 13, 2026 at 8:41 am

    Try calling recycle() on the bitmap.

    http://developer.android.com/reference/android/graphics/Bitmap.html#recycle%28%29

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

Sidebar

Related Questions

I have the basic xml setup... <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <android.support.v4.view.ViewPager android:id=@+id/viewpager android:layout_width=wrap_content
I have a very basic table with few columns. It has 15 records in
I have a very simple Activity to record audio using MediaRecorder . Basic start/stop
I have an Android widget that has a configure activity. I also have an
I have a very basic Activity at the moment. It creates a GLSurfaceView and
I have an application that contains a main Activity, which has a very simple
I have tried writing primitive activity for scanning USB port and displaying basic info
I have developed a basic UI activity page in android with a TextView and
I have created a basic ListView and added a TextView and ImageView in it.
I have a fairly basic app that only has two Activities, the splash screen

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.