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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:28:24+00:00 2026-05-28T16:28:24+00:00

SETUP : I have this app which has 4 activities in a linear path,

  • 0

SETUP :

I have this app which has 4 activities in a linear path, really simple navigation :
A -> B -> C -> D

All the activities share the same background image and all have a couple of regular buttons, a textview or an edittext. All of which are defined in separate views xml files.

The background is a gradient and is kind of heavy. Around 3 megs as an uncompressed bitmap.

The app does nothing yet, the only logic in it, is for starting activities and closing them on button clicks

I tried to use MAT to find a memory leak but couldn’t find anything. The biggest retained size in my app is 656(ko?) the total retained size for the app is 1520(ko?) and I can’t find any object that would be duplicated.
Which by the way completely contradicts dumpsys which shows 27300(ko?) allocated

PROBLEMS :

  1. When I navigate UP, I see an increase of memory usage equivalent to the background size.
  2. When I navigate DOWN, closing the activities with the back button or a finish command, the memory usage of the app does not decrease.
  3. If I go from A to D then back to B and rotate the screen, the app force closes with an OutOfMemory Exception.

QUESTIONS :

Update : I guess the real question is why do I have a huge memory leak(5 megs at a time) with a 27megs app size at freeze time and I can not see it in the MAT ?

  1. Why would Android decompress multiple times the same background, once per activity ? Seems inefficient.
  2. Is it possible to overcome this problem by using themes or will I see the same “allocate 1 background by activity” weirdness ?
  3. Why are the activities not reclaimed when closed ?
  4. Why are MAT and dumpsys presenting different numbers ?

CLUES

At exactly the same time I have :
dumpsys meminfo :

Applications Memory Usage (kB):
Uptime: 74006853 Realtime: 110962243

** MEMINFO in pid 22683 [com.kayenko.sosadresse] **
                    native   dalvik    other    total
            size:    20820     5767      N/A    26587
       allocated:    18751     2901      N/A    21652
            free:      312     2866      N/A     3178
           (Pss):     1357      201    16782    18340
  (shared dirty):     2264     1804     5456     9524
    (priv dirty):     1280      116    16032    17428

 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        0       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:       18    Proxy Binders:       16
Death Recipients:        1
 OpenSSL Sockets:        0

 SQL
               heap:        0         MEMORY_USED:        0
 PAGECACHE_OVERFLOW:        0         MALLOC_SIZE:        0

And this dominator tree :

MAT Dominator tree

Thansk to anyone with a clue on what I’m suppose to look for.

  • 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-28T16:28:25+00:00Added an answer on May 28, 2026 at 4:28 pm

    Memory is a very tricky subject in Android.

    Every app gets a heap memory limit depending on the device. This heap memory is the dalvik memory plus the native memory, and you can see it as the total column in the dumpsys meminfo results. The dalvik memory deals with everything except with the bitmaps, that are allocated in the native memory (this is true for Android versions before Honeycomb).

    Having said that I can only answer to some of your questions:

    1. As far as I know, Android will always allocate memory for Bitmaps, even if they are the same. Therefore, in your case, every activity allocates memory for your background.

    2. I don’t know if its better to work with themes, you’ll have to try that.

    3. On one hand, activities are not reclaimed while the device has enough memory to deal with the next activity. Every activity is pushed to a pile from where it is recovered when you pressed the back button. In case Android needs more memory it removes one activity from the pile deallocating its memory (going back to question number one, maybe this is the reason for not sharing memory). On the other hand, you can set the activities launchMode to change this behaviour (have a look here).

    4. I think MAT doesn’t show native memory data. Use dumpsys meminfo‘s native column to see how much allocated memory for Bitmaps you have.

    I have had hard times dealing with OutOfMemory problems myself. Now I have a much more clear idea
    of how it works and I am able to work with large files without running out of memory. I would highly recommend these two resources that helped me a lot:

    • How to discover memory usage of my application in Android
    • Google I/O 2011: Memory management for Android Apps (extremely useful!)

    Good luck!

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

Sidebar

Related Questions

I have a Rails 2.3.11 app which has two key Models: Activity Transaction Live
I have an app out which displays this link in a web view when
Greetings, I hope someone has the patience to read this. I have a setup
I have this setup where in my development copy I can commit changes on
On my portfolio page I have this setup: <div id=portfolio> <ul id=sites> <li> <h3><a
I have this following setup, a textarea named with some data in it that
I have this membership site setup on my local machine using the ASP.NET membership
I have this test case def setUp(self): self.user = User.objects.create(username=tauri, password='gaul') def test_loginin_student_control_panel(self): c
I have this nice little MSBuild-based daily build setup that I use on my
I have setup my windows in a certain way. How do I save this

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.