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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:53:25+00:00 2026-05-26T07:53:25+00:00

My activity keeps a certain number of references to preview images from the camera

  • 0

My activity keeps a certain number of references to preview images from the camera in a Map object. This takes a lot of memory. I’m monitoring the memory usage using:

    Runtime runtime = Runtime.getRuntime();
    long allocated = runtime.totalMemory();
    long free = runtime.freeMemory();
    long used = allocated  - free;

When I kill my app (back key), the activity is destroyed. When I start my app again, I can see that the memory was not cleared. The “used” figure starts at the same value and then goes up as new frames arrive.

When I look at the “dominator_tree” after I “Dump HPROF”, I can see two instances of my activity, both taking a lot of memory.

When I override onDestroy() and I clear() the preview frames map object, this doesn’t seem to happen.

I’m probably missing something here but I thought all memory should be deallocated after my activity is destroyed (after the garbage collection process), why do I have to manually clear() the map? Other objects I create don’t seem to require this.

I tried setting android:launchMode=”singleInstance” but this doesn’t seem to have any affect.

Thanks!

  • 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-05-26T07:53:25+00:00Added an answer on May 26, 2026 at 7:53 am

    in order to understand what’s happening, in the dominator tree, on your activity click with the right button, look for PATH to GC ROOT and select the option that exclude weak/soft/phantom references. That would give you an idea why the system could not destroy your activity (if you are leaking something or what else)

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

Sidebar

Related Questions

I cannot seem to figure out why my activity keeps running out of memory.
This activity is used for login. It post the username and password to a
My Activity creates an AsyncTask that loads data from a file and updates the
we start activity and do not calling finish() on existing activity it keeps existing
I have an activity which downloads images in background in a listView using AsyncTask,
From the Activity, I am creating a Handler to fire off my AsyncTask every
A main activity call a intent to do something(like install a certain apk)and main
this guy keeps kicking in making my app freeze, any method to fix this
I would like to finish an activity from inside the onCreate method. When I
I have defined a global variable inside an activity, this variable changes depending on

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.