Stuck at “Dumping memory, app will freeze. Brrr.” message

I’m trying to use LeakCanary to detect memory leaks in my app, but it does not go further than the message “Dumping memory, app will freeze. Brrr.” I’ve been waiting for about 20 minutes or so, but no changes. Same behaviour on these devices:
1. Asus fonepad 8 (Android 5.0 stock)
2. Sony Xperia SP (Android 5.1.1 CM 12.1 custom)
3. HTC Desire C (Android 4.4 CM 11 custom)

I did everything as its advised in instruction:

  • JQuery doesn't work on WebView
  • Android ActionBar MenuItem LowerCase
  • Opening an email client on clicking a button
  • how to display progress while loading a url to webview in android?
  • How to use textview.getLayout()? It returns null
  • get list of all users connected using wifi tethering in android
  • public class ExampleApplication extends Application {
    
      @Override public void onCreate() {
        super.onCreate();
        LeakCanary.install(this);
      }
    }
    

  • Android - Canvas Black when using Flood-Fill
  • android jackson json object mapper array deserialization
  • android how to handle out of memory exception
  • Screen blinking when using a webview with flash
  • Android: How do you check if a particular AccessibilityService is enabled
  • Android SQLite “no such table” exception
  • 2 Solutions collect form web for “Stuck at “Dumping memory, app will freeze. Brrr.” message”

    If you’re on Android M you need to grant the “write external storage” permission or leak canary will hang for a long time with the brrr message. In your apps drawer, long click on the launcher for leak canary (like you were going to uninstall it) and drag up to “app info” and turn on the storage permission.

    You should add the RefWatcher to your fragment as well just like what is described on the project page: https://github.com/square/leakcanary

    LeakCanary.install() returns a pre configured RefWatcher. It also installs an ActivityRefWatcher that automatically detects if an activity is leaking after Activity.onDestroy() has been called.

    public class ExampleApplication extends Application {
    
      public static RefWatcher getRefWatcher(Context context) {
        ExampleApplication application = (ExampleApplication) context.getApplicationContext();
        return application.refWatcher;
      }
    
      private RefWatcher refWatcher;
    
      @Override public void onCreate() {
        super.onCreate();
        refWatcher = LeakCanary.install(this);
      }
    }
    

    You could use the RefWatcher to watch for fragment leaks:

    public abstract class BaseFragment extends Fragment {
    
      @Override public void onDestroy() {
        super.onDestroy();
        RefWatcher refWatcher = ExampleApplication.getRefWatcher(getActivity());
        refWatcher.watch(this);
      }
    }
    

    Besides, if you want to get the heap dump when memory leak happened, just open the Android Device Monitor from Android Studio, and select the tab “File Explorer”. In the directory /mnt/shell/emulated/0/Download/leakcanary/detected_leaks, you will find all the heap dump files.

    enter image description here

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.