3 ms·
> I gather Google's phone OS have something similar Android apps are written in Java. So the standard approach for doing this is to use Java's weak & soft refe
by antrix 16y ago
> I gather Google's phone OS have something similar
Android apps are written in Java. So the standard approach for doing this is to use Java's weak & soft references which basically tell the GC that, "hey, I've used this memory but if you really need it back, you can have it!".
http://developer.android.com/reference/java/lang/ref/SoftReference.html http://developer.android.com/reference/java/lang/ref/SoftRef...
- jon_hendry 16y agoAndroid also has the MemoryFile class, which can be set "purgeable". "MemoryFile is a wrapper for the Linux ashmem driver. MemoryFiles are backed by shared memory, which can be optionally set to be purgeable. Purgeable files may have their contents reclaimed by the kernel in low memory conditions (only if allowPurging is set to true). After a file is purged, attempts to read or write the file will cause an IOException to be thrown."