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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:41:55+00:00 2026-05-19T12:41:55+00:00

I have a fairly complex app – The UI Activity launches a Service and

  • 0

I have a fairly complex app –

The UI Activity launches a Service and sets up 2 way AIDL callbacks so the two can communicate.

The service runs forever (unless hits ‘off’ button in UI Activity).

The problem is when the user exits the Activity, the Activity memory is not released.
-The amount of memory used by my app is the same even if the UI Activity has been closed.
-The heap still shows mapTiles and other UI crap on it even if the UI Activity has been closed.

So my guess is somehow the Service is holding references to the Activity. I know the many articles warning about leaking the Activity Context. The Service only references the Activity through a Weak Reference stored at Application scope. (a class that extends Application)

Is there any way to find what specifically is referencing the Activity? The dominator tree shows mapTiles and ListView layouts eating all my memory… but I can’t find the reference to the Activity which is keeping that stuff alive.

Also, is there a way to dump an HPROF heap dump thing if OutOfMemoryException occurs?

  • 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-19T12:41:56+00:00Added an answer on May 19, 2026 at 12:41 pm

    The problem is when the user exits the
    Activity, the Activity memory is not
    released.

    There is no “exit Activity” in Android. Calling finish() or pressing back on the activity does not remove objects from memory that the activity used. Android inherently takes care of this itself at some random point in the future.

    If you want your objects to be released from memory at the moment the activity finishes, you need to manually release them yourself.

    Edit: The class that can be used to find memory usage is the ActivityManager.

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

Sidebar

Related Questions

I have a Map activity in a fairly complex layout. As such, I can't
In my ASP.NET MVC app, I have a fairly complex edit page which combines
I have a fairly complex CLR stored procedure. What is the best way to
So I have a fairly complex activity the parent being a linearlayout with a
I have a fairly complex web app that was built (by a contractor) to
I have a fairly complex android app, the contents of the 'layout' folder is
For my app, I have a fairly complex set of configuration options that user
I'm part way through building a fairly complex HTML5 web app, that retrieves its
I have an android app that is getting fairly large and complex now, and
I have a fairly complex query in SQL that performs a count across two

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.