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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:04:03+00:00 2026-06-06T03:04:03+00:00

My android app is taking more and more memory over time. I took a

  • 0

My android app is taking more and more memory over time. I took a heap dump and analyzed it with MAT.

Here’s the main leak suspect :

So it seems like one of my activities isn’t cleared from memory after I quit the app (with back button) then when I restart the app a new instance is created and fills in the memory.

Now if they’re PhantomReferences why the memory isn’t cleared after a while or when I quit the app? The memory is never cleared even when I use other app etc. The only way to completely close the app is to use a task manager to manually kill the app.

What can I do to avoid this anarchic memory consumption ?

EDIT:

I found the problem!
Each activity was setting up a CustomExceptionHandler with Thread.setDefaultUncaughtExceptionHandler() and that CustomExceptionHandler was keeping a reference to the context. So I got rid of the context reference and I ‘nulled’ the DefaultUncaughtExceptionHandler in the onDestroy() method. That’s really better now!

  • 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-06T03:04:05+00:00Added an answer on June 6, 2026 at 3:04 am

    I would use the dominator tree functionality of MAT to find out what is above those references, this may give you an idea of which Activity is the culprit.

    Make sure you haven’t passed a Context anywhere and held a reference to it, this is a classic android memory leak and it’s really easy to do!

    Although some static analysis tools frown on this, in the onDestroy() methods of your Activity you can null all your local variables (except primitives), it helps to nudge the garbage collector sometimes and can make for an easier to analyse heap dump in MAT.

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

Sidebar

Related Questions

I have an Android app with a ListActivity in the main view. The list
I made an android app in which I am taking the date of birth
I wanted to write an Android and/or an iPhone app that entails taking a
I'm having an android app in which I'm taking a picture using the android
I've already integrated facebook login in my Android app but my problem is here:-
I'm looking for a list of Android phones and their respective maximum app memory
I am starting an android camera app for taking pictures. When I ctrl-shift-O to
I'm taking an android class now, so I am somewhat new to android app
My android app has a two word app name, and the 2nd word doesn't
My android app project need to add a new function of saving the click

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.