4 ms·
It'll be interesting to see if Snow Leopard's NSPurgeableData and related stuff moves to iPhone OS. (I gather Google's phone OS have something similar). That'd
by jonhendry 17y ago
It'll be interesting to see if Snow Leopard's NSPurgeableData and related stuff moves to iPhone OS. (I gather Google's phone OS have something similar).
That'd let developers have cached data that the OS knows it can blow away safely if memory gets low. The app then just regenerates the cache when necessary.
If iPhone OS could look around running processes for purgeable data, it could avoid or postpone killing apps outright. That would only be necessary if purging wasn't sufficient.
In fact, this seems a lot more useful on a swap-free phone than on OS X itself.
- antrix 17y 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 17y 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."