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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:01:39+00:00 2026-06-11T21:01:39+00:00

I have a lrucache that could contain static data, so that even if my

  • 0

I have a lrucache that could contain static data, so that even if my app is closed when user returns he can find data faster.

However this takes about 10-15 MB of memory and so I’d like to make an if branch like this

if(deviceOverallRAM > treshold)
      preserve static memory on app exit
else
      clear static memory on app exit

So, can I get device’s ram, maybe through some hidden api? And what would be a good value for the treshold?

  • 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-11T21:01:40+00:00Added an answer on June 11, 2026 at 9:01 pm

    To do this pre-API 16 you have to read the proc/meminfo file of the android kernel:

     public long getTotalMemory() {  
    
        String str1 = "/proc/meminfo";
        String str2;        
        String[] arrayOfString;
        long initial_memory = 0;
        try {
        FileReader localFileReader = new FileReader(str1);
        BufferedReader localBufferedReader = new BufferedReader(    localFileReader, 8192);
        str2 = localBufferedReader.readLine();//meminfo
        arrayOfString = str2.split("\\s+");
        for (String num : arrayOfString) {
        Log.i(str2, num + "\t");
        }
        //total Memory
        initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024;   
        localBufferedReader.close();
        return initial_memory;
        } 
        catch (IOException e) 
        {       
            return -1;
        }
      }  
    

    Source: this question

    However, in API 16 and onward, you can use the following code to retrieve the total memory:

    ActivityManager actManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    MemoryInfo memInfo = new ActivityManager.MemoryInfo();
    actManager.getMemoryInfo(memInfo);
    long totalMemory = memInfo.totalMem;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
Have one Doubt In MVC Architecture we can able to pass data from Controller
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
Have such a problem, hope you'll help me.. Can't find anywhere. Here is the
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL
I have a JSP which shows data by many aggregation types. E.g. By market,
have been trying couple of hours now to make my iphone app universal. The
Have a look at the following code to find X^y. /* Find exponent in

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.