I have some questions about the cache directory in android.
Does anyone knows the limit for each app's cache directory?
Also what will happen if there is not enough disk space to cache data? All I know is when the device runs low on storage, the files here (cache directory)will be the ones that get deleted first and each app has its own cache directory. Now, are the files of other app's cache directory will be cleared to accommodate my app's request to add files in the cache dir when there is not enough storage?
The size of cache you can specify is limited by the amount of physical memory and paging space available to the system. The shared class cache consists of memory mapped files that are created on disk and remain when the operating system is restarted.
Regardless of the specified size, no document that is greater than 1073741824 bytes is cached. This restriction applies even if the cache has available space. Hermann.
The default data cache size is an absolute value, and the minimum size for the cache size is 256 times the logical page size; for 2KB, the minimum is 512KB: for 16KB, the minimum is 4MB. The default value is 8MB.
There is no per-application limit for the cache directory. While Linux has a quota subsystem built-in, it is not used by Android. Applications share the cache filesystem without any real constraints. As it fills up, the Device Storage Monitor sends out an ACTION_DEVICE_STORAGE_LOW broadcast and calls a method of the Package Manager Service that sends a "freecache" command to the Install Daemon. The installd process then walks through the cache directory deleting files without regard to the owning application or modification date until the amount of free space available is above some threshold.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With