Skip to content

Instantly share code, notes, and snippets.

@talhahasanzia
Created May 21, 2018 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talhahasanzia/7d8a7d1444fc2f8901352b31e7fb92c4 to your computer and use it in GitHub Desktop.
Save talhahasanzia/7d8a7d1444fc2f8901352b31e7fb92c4 to your computer and use it in GitHub Desktop.
Calculating LRU limit for different devices (as suggested by guide)
public LRUCalculator{
public static int getMemorySize(Context context){
int memClass = ( ( ActivityManager )context.getSystemService( Context.ACTIVITY_SERVICE ) ).getMemoryClass();
int cacheSize = 1024 * 1024 * memClass / 8;
return cacheSize;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment