The Market cache has been a source of grievance for many Android/G1 users. Applications under Android store data in caches that are cleaned up when memory is running low. The G1 has an unimpressive amount of onboard memory, and the Market browser has a cache that cannot be manually cleared. This has lead to many individuals performing factory data resets on their phones just to reclaim the sequestered memory.
The factory data reset is not the best approach. In fact, I would say that the best approach is to do nothing at all about the problem. By virtue of Android’s memory manager, caches are cleared automatically when memory is needed. For example, if the foreground task needs to do something memory-intensive and there are some background tasks and caches, some of the tasks could be killed or caches could be cleared to make room. So… the problem solves itself.
One does not need to manually reclaim the memory, but what’s wrong with doing it anyway? I mean, it does get rid of the low-memory warnings that are so distressing to some. However, the biggest problem with clearing caches is the act itself. Caches perform the useful function of storing objects so that they need not be computed or fetched again, saving processor, networking, and power resources. One can even say that memory exists mainly for the purpose of caching. Therefore, it would be optimal to fill the memory as much as possible with cache. The system that Google set up is almost perfect — it allows the memory to fill with cached data, clearing bits at a time only when needed for a foreground task.
But why isn’t it perfect? Well, I had mentioned the low-memory warnings earlier. When the average user sees one of these, he/she thinks that the phone is about to explode. It’s not; rather, it’s a sign that the memory manager is doing its job. The psychological aspect of the problem can be resolved by either removing this warning or making it appear more benign, reserving the real warning for when the memory is really running out.
In the interim, I’m going to hang onto my caches and encourage you to do the same. There is no harm in taking the need-based memory management approach. Remember, unused memory is wasted memory.