Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android cache background process is increasing continuously

In my android application named "PriceDekho" the cache background process takes too much space. First when i start the application the application takes arround 30MB (I think its OK) but the problem is when i surfing the application pages then this size is increasing continuously upto (200 MB). This appliction "Cache background process" also varying with the mobile RAM size. If the mobile RAM size is 2GB then this application "Cache background process" size goes upto 500 to 700 MB.

My application is having only 5 to 6 screens. I just need to stabilize the cached background size.

How can i clear the application cached size? Please help.

enter image description here

enter image description here

like image 650
Manish Agrawal Avatar asked Mar 22 '15 11:03

Manish Agrawal


People also ask

Is it good to clear cache on Android?

Clearing your Android app cache can help fix speed issues and free up storage space. If you need more storage, clear the cache of the apps that take up the most space. Clearing your app cache every few months will help streamline your phone and keep it from getting too full.

How do I limit cache size on Android?

Tap the “hamburger menu” (three horizontal lines in the upper left corner), scroll down on the sidebar, and tap Settings. In the resulting window, scroll down and tap Cache size. In the resulting window (Figure A), tap to enable the cache size best suited for your device.

What is cache cleanup on my phone?

When you use a browser, like Chrome, it saves some information from websites in its cache and cookies. Clearing them fixes certain problems, like loading or formatting issues on sites.

How do I clear all cache on Android?

Open your browser. Android browser: Go to Menu > More > Settings or Menu > Settings > Privacy & Security. Chrome: Go to Menu > Settings > Privacy. Android browser: Tap Clear cache, Clear history, and Clear all cookie data as appropriate.


1 Answers

It sounds like you have memory leaks which the Garbage Collector can not remove. For example if you need to have a reference to the Context from a non-context class which is never released there. Most of the time Android Studio will point those out but you can try to use LeakCanary and search for them.

Add the dependency

dependencies {
   debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
 }

and use it in your Application class. Create one if you don't have it already.

public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
      // This process is dedicated to LeakCanary for heap analysis.
      // You should not init your app in this process.
      return;
    }
    LeakCanary.install(this);
    // Normal app init code...
  }
}
like image 64
Murat Karagöz Avatar answered Oct 13 '22 06:10

Murat Karagöz