leakcanary

how to use leakcanary, how to add leakcanary as a jar to build a apk with .mk file

做~自己de王妃 提交于 2019-12-30 17:36:32
问题 LeakCanary is a memory leak detection library for Android and Java. LeakCanary My project is based on android make file system, which relies on some android internal interfaces and custom methods. How can I add the LeakCanary as a lib into my app to detect memory leak. My solution: First, I have to build the LeakCanary as a jar file, but how to. as it's a gradle directory structure, and I have never used Gradle before. Any tip is precious. 回答1: LeakCanary is not just a JAR - it contains not

MainActivity leaked using leakcanary

不羁的心 提交于 2019-12-13 11:37:51
问题 I am using Leak Canary to track memory leak and it says the following were leaked: static hk.o references ht.a leaks MainActivity instance what is the hk.o and ht.a ? I dont have them in my MainActivity. 回答1: Those classes are third party library classes . You may take your MainActivity instance as an argument and pass in which class's instance belong to library. You could use ApplicationContext as an argument if it's not necessary to pass in Activity. 回答2: I think those are pro guarded

How to ignore certain classes from LeakCanary?

╄→гoц情女王★ 提交于 2019-12-12 19:23:42
问题 Can someone give me a working example of how to ignoring certain classes from LeakCanary? I was looking at this example for ignoring certain classes from third party library in LeakCanary, but I couldn't figure out where to put this in my application. I put this in my Application class, but there are error from these variables and methods: isInAnalyzerProcess, enableDisplayLeakActivity, application, androidWatcher public class DebugExampleApplication extends ExampleApplication { protected

Facebook is causing my activity to leak

佐手、 提交于 2019-12-11 00:26:56
问题 I'm using LeakCanary version 1.4-beta2 and I have just added Facebook sdk in my app. More precisely I have only added in MyApplication class this code in onCreate : FacebookSdk.sdkInitialize(getApplicationContext()); Yet I get this error from LeakCanary : In css.demo.debug:1.0:1. * css.demo.main.projects.ProjectsActivity has leaked: * GC ROOT static com.facebook.appevents.internal.ActivityLifecycleTracker.currentFuture * references java.util.concurrent.ScheduledThreadPoolExecutor

Leakcanary shows fragment leak with AppCompatActivity and FragmentStatePagerAdapter

流过昼夜 提交于 2019-12-10 18:26:29
问题 I've been having this issue for a while now and I really don't know what else to try. I've stuck Leakcanary on my project so I can force myself to learn android 'the right way' without picking up patterns that cause memory leaks.. I'm building an app and I've stripped it down a lot and I still see this leak happening. I have an Activity which has a viewpager inside and instantiates 10 fragments. If I turn the device everything seems fine, it's not until I press on 'Home' that I get the

How can I exclude a class from LeakCanary?

天大地大妈咪最大 提交于 2019-12-10 15:58:33
问题 I'm doing this: ExcludedRefs excludedRefs = AndroidExcludedRefs.createAppDefaults() .clazz("androidx.lifecycle.ReportFragment") .reason("Very annoying report fragment leak that isn't a leak apparently") .alwaysExclude() .build(); LeakCanary .refWatcher(context) .listenerServiceClass(DisplayLeakService.class) .excludedRefs(excludedRefs) .watchDelay(10, TimeUnit.SECONDS) .buildAndInstall(); And yet I'm still getting the ReportFragment was never GCed but no leak found . I also get that for one

How to treat memory leaks using the new AndroidProfiler

浪尽此生 提交于 2019-12-09 11:08:26
问题 I'm trying to learn how to identify and treat memory leaks in my App. I'm reading this great article, but I'm a bit confused about how to apply that in the new "Android Profiler" tool, that came with Android Studio 3.0. I'have a test application and LeakCanary is pointing that my App has memory leaks. In fact, when I run the profiler and press "dump java heap" I can see that there are 4 instances of my MyCollectionActivity and, when I click on these instances, I can see the details: But the

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

故事扮演 提交于 2019-12-04 16:15:22
问题 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: public class ExampleApplication extends Application { @Override public void

MapView v2 keeping Context around

家住魔仙堡 提交于 2019-12-04 02:07:55
When using the MapView from the latest google maps API, I am getting a memory leak because MapView is holding onto my activity. I used Leak Canary and have this trace D/LeakCanary﹕ * GC ROOT com.google.android.gms.location.internal.t.a D/LeakCanary﹕ * references com.google.android.gms.location.internal.s.a D/LeakCanary﹕ * references com.google.maps.api.android.lib6.d.v.c D/LeakCanary﹕ * references com.google.maps.api.android.lib6.d.aj.b D/LeakCanary﹕ * references com.google.maps.api.android.lib6.gmm6.c.p.a D/LeakCanary﹕ * references com.google.maps.api.android.lib6.gmm6.c.y.mParent D