Java – A background process that programmatically clears the cache

A background process that programmatically clears the cache… here is a solution to the problem.

A background process that programmatically clears the cache

I developed a simple application that loads four mobile WebViews side by side.
On a clean install, the app fully opens and loads these pages within 0.5 seconds.
However, if I minimize this app, for some reason its “cache background process” exceeds 200mbs! It seems completely unnecessary because the app loads lightning fast on a clean install

How to clear this cache when the application is minimized (onbackpressed, etc.).

enter image description here

Solution

You don’t need to worry about cache memory because the system reclaims it when needed.

However, if you still want to do something about it, you can call finish() in the onStop() method.

Alsothis is a great answer on this topic CommonsWare .

“cached background processes” usually refers to processes that do not
have a foreground activity and do not have a running service. These
processes are kept in memory simply because we have enough memory to
do so, and therefore, as you note, the user can switch back to these
processes quickly. As Android starts to need more system RAM for yet
other processes, the “cached background processes” tend to be the
processes that get terminated to free up system RAM

Related Problems and Solutions