未加星标

Force stop and clear cache Gary explains

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

If you have a problem with an app on your Android smartphone you may have read that you should do a “Force Stop” and then “Clear Cache” to fix it. And actually that might very well be exactly what you need to do. But why does that help? What does “Force stop” do and what is a cache? Let me explain.

Force Stop

At the heart of Android is the linux kernel, it is the component responsible for managing memory and processes along with a whole bunch of other resources. Whenever you start an app you are actually starting a Linux process.

A process is a logical container for a program (app). It is started by the kernel and is used as a way to share the system resources (including memory and CPU time) among all the running apps.Each process has an ID, known as the PID (Process ID); a priority, how important is it; its own address space, plus related pages of physical memory; and some state information: running (or runnable), sleeping, stopped and zombied.

See also:

Processes and threads Gary explains

April 12, 2016

The kernel’s job is to schedule CPU time and allocate memory to the process so that it can run. The way it works is that the kernel gives slices of CPU time to each of the running processes. If a processes is sleeping (because it is waiting for something like data from the network) then it doesn’t get any CPU time.This juggling of processes goes on at the millisecond level, very fast, and just like the frames of a cartoon, you get the appearance of smoothness and multiple programs running at once.

Finally, when an app exits, the kernel will clean up all the resources used by the app (like open files, allocated memory etc) and eventually delete the process that was created for that app.

Each app can be in one of several different states: running, paused or stopped. These are different to the process states, as defined by Linux, and represent the “Activity Lifecycle” as defined by Android. Google puts it like this, “as a user navigates through, out of, and back to your app, the Activity instances in your app transition through different states in their lifecycle.”

The interesting thing about Android is that it never kills an app directly.Instead, it kills the process in which the activity runs, destroying not only the activity but everything else running in the process, as well. It might do this whenit needs to free up RAM or auser can kill a process by using Force Stop in the Application Manager.


Force stop and clear cache   Gary explains

When everything is working smoothly, an app will transition from one activity state to another and will either eventually be killed off by Android (after moving to the stopped state) or it will just hang around in the background until the user brings it to the foreground again. However if things start to go wrong the app can misbehave. It might stop responding to certain events, it might get stuck in some kind of loop or it might just start doing unpredictable things.

In such cases the app might need to be killed off and then restarted. That is what Force Stop is for, it basically kills off the Linux process for the app and cleans up the mess!

The reason why using Force Stop is recommended when trying to fix a misbehaving app it is 1) it kills of the current running instance of that app and 2) it means that the app will no longer be accessing any of its cache files, which leads us to step 2: Clear Cache.

See also:

What is a kernel Gary explains

March 30, 2016

Clear Cache

After the app has been killed the next step is to delete the data in the cache directory. When a application needs a temporary file, a pre-processed file, or when it wants to keep a local copy of a file which was downloaded from the Internet then it will get placed in the app’s cache directory. Each app has its own directory where it can put working files.

The idea is as follows. If an app downloads files or data from the Internet then it would be a waste of bandwidth plus a waste of time to download the very same files every time the app starts. Instead any files that need downloading from the Internet can be downloaded once and then stored in the cache. From time to time the app can check if those temporary copies are still valid and refresh the cache if needed.

Another example would be a if the app needs to process a file, maybe perform some decoding or decryption on some data. Rather than performing this decoding or decryption every time the app launches, which would use a lot of CPU cycles, the app can do it once and then store the result in the cache. Again, the app could check the validity of the processed file and refresh the cache if needed.


Force stop and clear cache   Gary explains

The reason these are temporary files is that the app should not rely on these files being present as Android candelete them when a device runs low on storage. In these cases the app just simply downloads the data again, or processes the files again and creates new ones in its cache.

Apps can also store files more permanently by using the app data directory. This is different to the cache directory and is designed for persistent files owned by the app. Since Android is able to delete files in the cache directory without notifying the app, it is also safe for users to delete those files via the “Clear Cache” button!

See also:

How to clear app data and cache in Android 6.0 Marshmallow

October 12, 2015

This can help fix misbehaving apps as it clears out the pool of temporary files and forces the app to recreate them and so gives the app a kind of fresh start. This can often fix the problem as the error was in the processing of a temporary or cached file.

A side benefit of clearing the cache is that it frees up storage space. So if you are running low of internal storage then clearing the cached data for all apps can help.


Force stop and clear cache   Gary explains
Wrap-up

If you need instructions on how to clear an apps’s cache then there are a number of excellent guides on Android Authority including how to clear app data and cache in Android 6.0 Marshmallow and how to regain storage space by cleaning the cache on your Android device . Using Force Stop is very similar, just follow the instructions in the linked guides, but tap on “Force Stop” rather than “Clear Cache.”

What are your experiences with Force Stop and Clear Cache? Are there any apps which you find use a lot of storage space for cached files? Please let me know in the comments below.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: AndroidCPULinux
分页:12
转载请注明
本文标题:Force stop and clear cache Gary explains
本站链接:http://www.codesec.net/view/529897.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(13)