Last active
December 19, 2015 03:39
-
-
Save mataanin/5891668 to your computer and use it in GitHub Desktop.
Android: Calculating memory cache size based on the memory available on the device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from Contacts List example | |
public static int calculateMemCacheSize(float percent) { | |
if (percent < 0.05f || percent > 0.8f) { | |
throw new IllegalArgumentException("setMemCacheSizePercent - percent must be " | |
+ "between 0.05 and 0.8 (inclusive)"); | |
} | |
return Math.round(percent * Runtime.getRuntime().maxMemory() / 1024); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment