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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:40:06+00:00 2026-05-28T01:40:06+00:00

I have an application which has (mostly) images in its layouts. As I understand,

  • 0

I have an application which has (mostly) images in its layouts. As I understand, Android is supposed to free the memory when the activity is not needed anymore. Thus, I am not releasing this Drawables used by my app’s layouts when the Activity goes onPause() manually. I understand Android should do this.

Then, I use this code to check the memory status:

{
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    android.app.ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);

    Log.i("MEMCHECK", " memoryInfo.availMem " + memoryInfo.availMem + "\n" );
    Log.i("MEMCHECK", " memoryInfo.lowMemory " + memoryInfo.lowMemory + "\n" );
    Log.i("MEMCHECK", " memoryInfo.threshold " + memoryInfo.threshold + "\n" );

    android.os.Debug.MemoryInfo[] memoryInfoArray = activityManager.getProcessMemoryInfo(pids);
    for(android.os.Debug.MemoryInfo pidMemoryInfo: memoryInfoArray) {
        Log.i("MEMCHECK", " pidMemoryInfo.getTotalPrivateDirty(): " + pidMemoryInfo.getTotalPrivateDirty() + "\n");
        Log.i("MEMCHECK", " pidMemoryInfo.getTotalPss(): " + pidMemoryInfo.getTotalPss() + "\n");
        Log.i("MEMCHECK", " pidMemoryInfo.getTotalSharedDirty(): " + pidMemoryInfo.getTotalSharedDirty() + "\n");
}

On every created activity, the memory footprint grows (the heap – getTotalPrivateDirty() ). I don’t wanna do this since every ‘kb’ of memory in my app is really important.

Also, when this callback is processed:

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
    public void onPictureTaken(byte[] imageData, Camera c) {

    }
}

Empty, just like that. The heap grows from 10MB to 20MB. 100%. Is this normal? How to avoid?

  • 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-28T01:40:07+00:00Added an answer on May 28, 2026 at 1:40 am

    For images and Callbacks you need to free memory manually, instead being dependent on garbage collector.
    Also you need to take care of context of the views. whereas possible assign context at lowest level, like if a view is to be used only in an activity, assign it activity context, if a listener/callback should be used only in view, assign view context to it.

    And also you can unbind xml drawables manually.

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

Sidebar

Related Questions

I have an application which has to live as a service, I create an
I have an application which has a similar interface to Visual Studio, in that
I have an application which has a Projects table and a Users table. In
I have an AJAX application which has used CSS divs to create panels on
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have an MVC application which has a set of fields for contact details
I have an iphone application which has about 4 tabs. How do I force
I have a Windows application which has a browser in it. The Windows application
I have a Java Application which has to load an DLL with a few
We have a Flex application which has several 'pages' worth of content. Each time

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.