xref: /aosp_15_r20/external/leakcanary2/docs/changelog.md (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1*d9e8da70SAndroid Build Coastguard Worker
2*d9e8da70SAndroid Build Coastguard Worker# Change Log
3*d9e8da70SAndroid Build Coastguard Worker
4*d9e8da70SAndroid Build Coastguard WorkerPlease thank our [contributors](https://github.com/square/leakcanary/graphs/contributors) �� �� ��.
5*d9e8da70SAndroid Build Coastguard Worker
6*d9e8da70SAndroid Build Coastguard WorkerI've started working on LeakCanary 3.0 so new 2.x releases only contain bug fixes and new known leak patterns.
7*d9e8da70SAndroid Build Coastguard Worker
8*d9e8da70SAndroid Build Coastguard Worker## Version 2.13 (2024-01-01)
9*d9e8da70SAndroid Build Coastguard Worker
10*d9e8da70SAndroid Build Coastguard Worker* �� [#2565](https://github.com/square/leakcanary/issues/2565) Fix AndroidX Fragments incorrectly marked as leaking if detached but not destroyed.
11*d9e8da70SAndroid Build Coastguard Worker* �� [#2568](https://github.com/square/leakcanary/issues/2568) Fixed missing `RECEIVER_EXPORTED` flag when calling `registerReceiver()` on API 34+.
12*d9e8da70SAndroid Build Coastguard Worker* �� [#2555](https://github.com/square/leakcanary/issues/2555) Binder stubs are now called out in leak traces.
13*d9e8da70SAndroid Build Coastguard Worker* �� [#2601](https://github.com/square/leakcanary/pull/2601) Added several known manufacturer & framework leaks.
14*d9e8da70SAndroid Build Coastguard Worker
15*d9e8da70SAndroid Build Coastguard Worker## Version 2.12 (2023-06-29)
16*d9e8da70SAndroid Build Coastguard Worker
17*d9e8da70SAndroid Build Coastguard Worker* �� [#2527](https://github.com/square/leakcanary/issues/2527) `LifecycleRegistry` in `androidx.lifecycle:lifecycle-runtime` was migrated to kotlin and its `mState` field name changed to `state` which broke LeakCanary expectations.
18*d9e8da70SAndroid Build Coastguard Worker* �� [#2545](https://github.com/square/leakcanary/pull/2545) Added several known manufacturer & framework leaks.
19*d9e8da70SAndroid Build Coastguard Worker
20*d9e8da70SAndroid Build Coastguard Worker
21*d9e8da70SAndroid Build Coastguard Worker## Version 2.11 (2023-05-17)
22*d9e8da70SAndroid Build Coastguard Worker
23*d9e8da70SAndroid Build Coastguard Worker* �� [#1764](https://github.com/square/leakcanary/issues/1764) Ignore phantom classes that were unloaded than reloaded (long time LeakCanary bug).
24*d9e8da70SAndroid Build Coastguard Worker* �� [#2471](https://github.com/square/leakcanary/issues/2471) Fix LeakCanary introducing a weird leak in Google's CI infra.
25*d9e8da70SAndroid Build Coastguard Worker* �� [#2496](https://github.com/square/leakcanary/issues/2496) Fix broken ViewModel leak detection
26*d9e8da70SAndroid Build Coastguard Worker
27*d9e8da70SAndroid Build Coastguard Worker## Version 2.10 (2022-11-10)
28*d9e8da70SAndroid Build Coastguard Worker
29*d9e8da70SAndroid Build Coastguard Worker### Experimental Neo4j heap dump exploration
30*d9e8da70SAndroid Build Coastguard Worker
31*d9e8da70SAndroid Build Coastguard Worker`shark-cli` has a new experiment `neo4j` command that will convert a heap dump into an embedded Neo4j database and then open Neo4j Browser to explore the heap dump.
32*d9e8da70SAndroid Build Coastguard Worker
33*d9e8da70SAndroid Build Coastguard Worker```
34*d9e8da70SAndroid Build Coastguard Workerbrew install leakcanary-shark
35*d9e8da70SAndroid Build Coastguard Worker
36*d9e8da70SAndroid Build Coastguard Workershark-cli --process com.example.app.debug neo4j
37*d9e8da70SAndroid Build Coastguard Worker```
38*d9e8da70SAndroid Build Coastguard Worker
39*d9e8da70SAndroid Build Coastguard Worker![Neo4J heap dump](https://user-images.githubusercontent.com/557033/200693468-aa783bb4-9a5a-4a41-8b92-582d44b31b92.png)
40*d9e8da70SAndroid Build Coastguard Worker
41*d9e8da70SAndroid Build Coastguard Worker### Other bug fixes and improvements ����
42*d9e8da70SAndroid Build Coastguard Worker
43*d9e8da70SAndroid Build Coastguard Worker* �� [#2440](https://github.com/square/leakcanary/pull/2440) Add Android 13 `POST_NOTICICATIONS` permission as well as a new `LeakCanary.Config.showNotifications` config to disable notifications entirely.
44*d9e8da70SAndroid Build Coastguard Worker* �� [#2416](https://github.com/square/leakcanary/pull/2416) Add Android 13 monochrome icon.
45*d9e8da70SAndroid Build Coastguard Worker* �� [#2371](https://github.com/square/leakcanary/issues/2371) Fix db crash when navigating heap dump screen.
46*d9e8da70SAndroid Build Coastguard Worker* �� [#2393](https://github.com/square/leakcanary/issues/2393) Allow LeakCanary to be defined as an AndroidX Startup dependency.
47*d9e8da70SAndroid Build Coastguard Worker* �� [#2430](https://github.com/square/leakcanary/issues/2430) Fix ShortcutManager crash on Android TV.
48*d9e8da70SAndroid Build Coastguard Worker* �� [#2382](https://github.com/square/leakcanary/issues/2382) Fix heap dump close crash.
49*d9e8da70SAndroid Build Coastguard Worker
50*d9e8da70SAndroid Build Coastguard WorkerThis list reflects only a subset of all changes. For more details, see the [2.10 Milestone](https://github.com/square/leakcanary/milestone/25) and the [full diff](https://github.com/square/leakcanary/compare/v2.9.1...v2.10).
51*d9e8da70SAndroid Build Coastguard Worker
52*d9e8da70SAndroid Build Coastguard Worker## Version 2.9.1 (2022-04-20)
53*d9e8da70SAndroid Build Coastguard Worker
54*d9e8da70SAndroid Build Coastguard Worker### Preface
55*d9e8da70SAndroid Build Coastguard Worker
56*d9e8da70SAndroid Build Coastguard WorkerWhat are some things you'd like to see in a future LeakCanary 3 version? Tell me [on Twitter](https://twitter.com/Piwai)!
57*d9e8da70SAndroid Build Coastguard Worker
58*d9e8da70SAndroid Build Coastguard WorkerSome ideas I'm playing with:
59*d9e8da70SAndroid Build Coastguard Worker
60*d9e8da70SAndroid Build Coastguard Worker* Moving heap analysis leak visualisation to a separate single app (written with Compose!) available on the PlayStore.
61*d9e8da70SAndroid Build Coastguard Worker* Bumping Okio to 3.0
62*d9e8da70SAndroid Build Coastguard Worker* Multiplatform heap analysis? Analyze a JVM heap dump in your browser?!
63*d9e8da70SAndroid Build Coastguard Worker* Visualize the heap dominators / retained size as a treemap.
64*d9e8da70SAndroid Build Coastguard Worker* A backend for LeakCanary?
65*d9e8da70SAndroid Build Coastguard Worker
66*d9e8da70SAndroid Build Coastguard WorkerAnyway, that's still very much the future, let's talk about what's in `2.9.1` now!
67*d9e8da70SAndroid Build Coastguard Worker
68*d9e8da70SAndroid Build Coastguard Worker### New metrics in heap analysis metadata
69*d9e8da70SAndroid Build Coastguard Worker
70*d9e8da70SAndroid Build Coastguard WorkerI built LeakCanary to help fix leaks, but in doing so I accidentally wrote a fairly flexible heap dump parser. Since we're parsing the heap to find leaks anyway, we might as well report additional interesting metrics. Here's what you'll now see in the heap dump metadata:
71*d9e8da70SAndroid Build Coastguard Worker
72*d9e8da70SAndroid Build Coastguard Worker* Class count: count of loaded classes
73*d9e8da70SAndroid Build Coastguard Worker* Instance count
74*d9e8da70SAndroid Build Coastguard Worker* Primitive array count
75*d9e8da70SAndroid Build Coastguard Worker* Object array count
76*d9e8da70SAndroid Build Coastguard Worker* Thread count
77*d9e8da70SAndroid Build Coastguard Worker* Heap total bytes
78*d9e8da70SAndroid Build Coastguard Worker* Bitmap count
79*d9e8da70SAndroid Build Coastguard Worker* Bitmap total bytes
80*d9e8da70SAndroid Build Coastguard Worker* Large bitmap count (bitmaps with more pixels than 1.1x the pixels on screen)
81*d9e8da70SAndroid Build Coastguard Worker* Large bitmap total bytes
82*d9e8da70SAndroid Build Coastguard Worker* SQLiteDatabase in memory (open or closed, as well as their file path)
83*d9e8da70SAndroid Build Coastguard Worker
84*d9e8da70SAndroid Build Coastguard WorkerThis is just a first pass, feedback and ideas welcome!
85*d9e8da70SAndroid Build Coastguard Worker
86*d9e8da70SAndroid Build Coastguard Worker### Performance improvements
87*d9e8da70SAndroid Build Coastguard Worker
88*d9e8da70SAndroid Build Coastguard WorkerThe heap analysis now traverses the heap dump using `RandomAccessFile` instead of `FileChannel.transferTo()` and is now 40% faster on API 23 and 20% faster on newer APIs.
89*d9e8da70SAndroid Build Coastguard WorkerAlso, sticky class GC roots are now deduplicated, which great reduces the memory footprint of LeakCanary on API 23 ([#2324](https://github.com/square/leakcanary/pull/2324)). You can read about the related investigation [on py.hashnode.dev](https://py.hashnode.dev/of-sharks-and-heaps-of-sticky-marshmallows).
90*d9e8da70SAndroid Build Coastguard Worker
91*d9e8da70SAndroid Build Coastguard Worker### Breaking change:  FailTestOnLeakRunListener deleted
92*d9e8da70SAndroid Build Coastguard Worker
93*d9e8da70SAndroid Build Coastguard Worker`FailTestOnLeakRunListener`, `FailTestOnLeak` and `FailAnnotatedTestOnLeakRunListener` were deprecated in LeakCanary 2.8 as they rely on hacking the Android Test library internals which have since changed, and have been replaced by `LeakAssertions.assertNoLeak()` and the `DetectLeaksAfterTestSuccess` test rule. I was initially planning of keep these around, but as I tried to increase API level coverage in LeakCanary I needed to upgrade the Android Test library to a more recent version, and the hacks now had compilation errors. So they're gone: [#2282](https://github.com/square/leakcanary/commit/7152d6e2f8bea866e3bd5397b882d5098bed7d8b). If you can't use the test rules just yet, you're welcome to copy paste the listener implementations in your own codebase.
94*d9e8da70SAndroid Build Coastguard Worker
95*d9e8da70SAndroid Build Coastguard Worker### Other bug fixes and improvements ����
96*d9e8da70SAndroid Build Coastguard Worker
97*d9e8da70SAndroid Build Coastguard Worker* �� [#2367](https://github.com/square/leakcanary/pull/2367) Fixed `AndroidLeakFixes.FLUSH_HANDLER_THREADS` (`HandlerThread` can have a null `Looper`).
98*d9e8da70SAndroid Build Coastguard Worker* �� [#2286](https://github.com/square/leakcanary/issues/2286) Update Curtains to include Proguard rules and prevent `WindowCallbackWrapper` crashes.
99*d9e8da70SAndroid Build Coastguard Worker* �� [#2294](https://github.com/square/leakcanary/issues/2294) Fixed `WindowDelegateCallback.onMenuOpened()` crash.
100*d9e8da70SAndroid Build Coastguard Worker* �� [#2328](https://github.com/square/leakcanary/pull/2328) Fixed ToastEventListener leak. Sorry ��!
101*d9e8da70SAndroid Build Coastguard Worker* �� [#2310](https://github.com/square/leakcanary/issues/2310) Fixed crash when using WorkManager < 2.1.0.
102*d9e8da70SAndroid Build Coastguard Worker* �� [#2342](https://github.com/square/leakcanary/issues/2342) Fixed crash when `HashSet.map` is null (which isn't supposed to happen, oh well, Android ��‍♂️).
103*d9e8da70SAndroid Build Coastguard Worker* �� [#2117](https://github.com/square/leakcanary/issues/2117) Fixed StrictMode disk read violations.
104*d9e8da70SAndroid Build Coastguard Worker* �� [#2351](https://github.com/square/leakcanary/pull/2351) Fixed a race causing a startup crash.
105*d9e8da70SAndroid Build Coastguard Worker* �� [#2315](https://github.com/square/leakcanary/issues/2315) Fixed crash when using Okio 1.14.
106*d9e8da70SAndroid Build Coastguard Worker* �� [#2182](https://github.com/square/leakcanary/issues/2182) Fixed multi rescheduling of `BackgroundListener$checkAppInBackground`.
107*d9e8da70SAndroid Build Coastguard Worker* �� [#2360](https://github.com/square/leakcanary/issues/2360) Fixed SQLiteOpenHelper concurrent creation crash.
108*d9e8da70SAndroid Build Coastguard Worker
109*d9e8da70SAndroid Build Coastguard WorkerThis list reflects only a subset of all changes. For more details, see the [2.9 Milestone](https://github.com/square/leakcanary/milestone/23) and the [full diff](https://github.com/square/leakcanary/compare/v2.8.1...v2.9.1).
110*d9e8da70SAndroid Build Coastguard Worker
111*d9e8da70SAndroid Build Coastguard Worker
112*d9e8da70SAndroid Build Coastguard Worker## Version 2.8.1 (2022-01-06)
113*d9e8da70SAndroid Build Coastguard Worker
114*d9e8da70SAndroid Build Coastguard WorkerThis is a bugfix release, a quick follow up to `2.8` which had a few major issues ��. If you haven't yet, you should definitely read the `2.8` changelog.
115*d9e8da70SAndroid Build Coastguard Worker
116*d9e8da70SAndroid Build Coastguard Worker### Thanks
117*d9e8da70SAndroid Build Coastguard Worker
118*d9e8da70SAndroid Build Coastguard WorkerPlease thank
119*d9e8da70SAndroid Build Coastguard Worker[@dicosta](https://github.com/dicosta),
120*d9e8da70SAndroid Build Coastguard Worker[@Goooler](https://github.com/Goooler),
121*d9e8da70SAndroid Build Coastguard Worker[@plnice](https://github.com/plnice),
122*d9e8da70SAndroid Build Coastguard Worker[@preetha1326](https://github.com/preetha1326)
123*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests �� �� ��.
124*d9e8da70SAndroid Build Coastguard Worker
125*d9e8da70SAndroid Build Coastguard Worker### Crash fixes ������
126*d9e8da70SAndroid Build Coastguard Worker
127*d9e8da70SAndroid Build Coastguard WorkerThis patch release fixes not 1, not 2, but 3 crashes!
128*d9e8da70SAndroid Build Coastguard Worker
129*d9e8da70SAndroid Build Coastguard Worker* �� [#2268](https://github.com/square/leakcanary/pull/2268) WorkManager expedited request crashes before API 31.
130*d9e8da70SAndroid Build Coastguard Worker* �� [#2270](https://github.com/square/leakcanary/issues/2270) Updating `LeakCanary.config` crashes when `AppWatcher` is not installed.
131*d9e8da70SAndroid Build Coastguard Worker* �� [#2271](https://github.com/square/leakcanary/issues/2271) Analysis failure on API 25 because `HashMap$Entry` became `HashMap$HashMapEntry` (on API 25) before it finally changed to `HashMap$Node`.
132*d9e8da70SAndroid Build Coastguard Worker
133*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.8.1 Milestone](https://github.com/square/leakcanary/milestone/24) and the [full diff](https://github.com/square/leakcanary/compare/v2.8...v2.8.1).
134*d9e8da70SAndroid Build Coastguard Worker
135*d9e8da70SAndroid Build Coastguard Worker## Version 2.8 (2022-01-04)
136*d9e8da70SAndroid Build Coastguard Worker
137*d9e8da70SAndroid Build Coastguard WorkerNote: please update to `2.8.1` instead.
138*d9e8da70SAndroid Build Coastguard Worker
139*d9e8da70SAndroid Build Coastguard Worker### Preface
140*d9e8da70SAndroid Build Coastguard Worker
141*d9e8da70SAndroid Build Coastguard WorkerThe last release was 9 months ago. What happened?! Well, soon after releasing LeakCanary 2.7, I had my 2nd baby, a wonderful daughter ��. Having 2 young kids leaves a lot less time available for Open Source work... but it's worth it!
142*d9e8da70SAndroid Build Coastguard Worker
143*d9e8da70SAndroid Build Coastguard Worker― [P.Y.](https://twitter.com/Piwai)
144*d9e8da70SAndroid Build Coastguard Worker
145*d9e8da70SAndroid Build Coastguard Worker### Thanks
146*d9e8da70SAndroid Build Coastguard Worker
147*d9e8da70SAndroid Build Coastguard WorkerPlease thank
148*d9e8da70SAndroid Build Coastguard Worker[@aaronweihe](https://github.com/aaronweihe),
149*d9e8da70SAndroid Build Coastguard Worker[@alhah](https://github.com/alhah),
150*d9e8da70SAndroid Build Coastguard Worker[@Andre-max](https://github.com/Andre-max),
151*d9e8da70SAndroid Build Coastguard Worker[@AoraMD](https://github.com/AoraMD),
152*d9e8da70SAndroid Build Coastguard Worker[@BraisGabin](https://github.com/BraisGabin),
153*d9e8da70SAndroid Build Coastguard Worker[@breezenan](https://github.com/breezenan),
154*d9e8da70SAndroid Build Coastguard Worker[@Goooler](https://github.com/Goooler),
155*d9e8da70SAndroid Build Coastguard Worker[@iliaskomp](https://github.com/iliaskomp)
156*d9e8da70SAndroid Build Coastguard Worker[@Jeff11](https://github.com/Jeff11),
157*d9e8da70SAndroid Build Coastguard Worker[@jmnwong](https://github.com/jmnwong),
158*d9e8da70SAndroid Build Coastguard Worker[@IdioticMadman](https://github.com/IdioticMadman),
159*d9e8da70SAndroid Build Coastguard Worker[@keyur1sst](https://github.com/keyur1sst),
160*d9e8da70SAndroid Build Coastguard Worker[@lchen8](https://github.com/lchen8),
161*d9e8da70SAndroid Build Coastguard Worker[@leinardi](https://github.com/leinardi),
162*d9e8da70SAndroid Build Coastguard Worker[@Maragues](https://github.com/Maragues),
163*d9e8da70SAndroid Build Coastguard Worker[@mars885](https://github.com/mars885),
164*d9e8da70SAndroid Build Coastguard Worker[@mateuszkwiecinski](https://github.com/mateuszkwiecinski),
165*d9e8da70SAndroid Build Coastguard Worker[@matiash](https://github.com/matiash),
166*d9e8da70SAndroid Build Coastguard Worker[@maxxx](https://github.com/maxxx),
167*d9e8da70SAndroid Build Coastguard Worker[@preetha1326](https://github.com/preetha1326),
168*d9e8da70SAndroid Build Coastguard Worker[@SimonMarquis](https://github.com/SimonMarquis),
169*d9e8da70SAndroid Build Coastguard Worker[@slavonnet](https://github.com/slavonnet),
170*d9e8da70SAndroid Build Coastguard Worker[@Sonphil](https://github.com/Sonphil),
171*d9e8da70SAndroid Build Coastguard Worker[@summerlyr](https://github.com/summerlyr),
172*d9e8da70SAndroid Build Coastguard Worker[@SUPERCILEX](https://github.com/SUPERCILEX),
173*d9e8da70SAndroid Build Coastguard Worker[@utwyko](https://github.com/utwyko),
174*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers),
175*d9e8da70SAndroid Build Coastguard Worker[@ziranshang](https://github.com/ziranshang),
176*d9e8da70SAndroid Build Coastguard Worker[@zoltish](https://github.com/zoltish)
177*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests �� �� ��.
178*d9e8da70SAndroid Build Coastguard Worker
179*d9e8da70SAndroid Build Coastguard Worker### Improved support for data structure internals
180*d9e8da70SAndroid Build Coastguard Worker
181*d9e8da70SAndroid Build Coastguard Worker�� Inspired [by Android Studio](https://twitter.com/RalucaSauciuc/status/1343800565352996871), LeakCanary's node discovery during heap graph traversal is now abstracted away. This allows overlaying logical structure over common data structure internals.
182*d9e8da70SAndroid Build Coastguard Worker
183*d9e8da70SAndroid Build Coastguard Worker�� WHAT?!
184*d9e8da70SAndroid Build Coastguard Worker
185*d9e8da70SAndroid Build Coastguard Worker�� This means we can make known data structures look more like their APIs than their internals. For example, developers tend to think of setting a `HashMap` entry as `map["key"] = value` rather than `map.table[hash("key")].next.next.next = Node(value)`, which is what LeakCanary would previously show in its leak traces.
186*d9e8da70SAndroid Build Coastguard Worker
187*d9e8da70SAndroid Build Coastguard WorkerLet's look at a `HashMap` example:
188*d9e8da70SAndroid Build Coastguard Worker
189*d9e8da70SAndroid Build Coastguard Worker```kotlin
190*d9e8da70SAndroid Build Coastguard Workerclass CheckoutController {
191*d9e8da70SAndroid Build Coastguard Worker
192*d9e8da70SAndroid Build Coastguard Worker  val tabs = HashMap<String, Tab>()
193*d9e8da70SAndroid Build Coastguard Worker
194*d9e8da70SAndroid Build Coastguard Worker  fun addItemsTab(tab: Tab) {
195*d9e8da70SAndroid Build Coastguard Worker    tabs["ItemsTab"] = tab
196*d9e8da70SAndroid Build Coastguard Worker  }
197*d9e8da70SAndroid Build Coastguard Worker}
198*d9e8da70SAndroid Build Coastguard Worker```
199*d9e8da70SAndroid Build Coastguard Worker
200*d9e8da70SAndroid Build Coastguard WorkerIf the `Tab` instance holds on to a view, we might see a leak trace that would look like this:
201*d9e8da70SAndroid Build Coastguard Worker
202*d9e8da70SAndroid Build Coastguard Worker```
203*d9e8da70SAndroid Build Coastguard Worker│ ...
204*d9e8da70SAndroid Build Coastguard Worker├─ com.example.CheckoutController instance
205*d9e8da70SAndroid Build Coastguard Worker│    ↓ CheckoutController.tabs
206*d9e8da70SAndroid Build Coastguard Worker├─ java.util.HashMap instance
207*d9e8da70SAndroid Build Coastguard Worker│    ↓ HashMap.table
208*d9e8da70SAndroid Build Coastguard Worker├─ java.util.HashMap$Node[] array
209*d9e8da70SAndroid Build Coastguard Worker│    ↓ HashMap$Node[42]
210*d9e8da70SAndroid Build Coastguard Worker├─ java.util.HashMap$Node instance
211*d9e8da70SAndroid Build Coastguard Worker│    ↓ HashMap$Node.next
212*d9e8da70SAndroid Build Coastguard Worker├─ java.util.HashMap$Node instance
213*d9e8da70SAndroid Build Coastguard Worker│    ↓ HashMap$Node.value
214*d9e8da70SAndroid Build Coastguard Worker├─ com.example.Tab instance
215*d9e8da70SAndroid Build Coastguard Worker│ ...
216*d9e8da70SAndroid Build Coastguard Worker```
217*d9e8da70SAndroid Build Coastguard Worker
218*d9e8da70SAndroid Build Coastguard WorkerWith the improved data structure support, the leak trace is much clearer (also note how the `ItemsTab` string key is now surfaced):
219*d9e8da70SAndroid Build Coastguard Worker
220*d9e8da70SAndroid Build Coastguard Worker```
221*d9e8da70SAndroid Build Coastguard Worker│ ...
222*d9e8da70SAndroid Build Coastguard Worker├─ com.example.CheckoutController instance
223*d9e8da70SAndroid Build Coastguard Worker│    ↓ CheckoutController.tabs
224*d9e8da70SAndroid Build Coastguard Worker├─ java.util.HashMap instance
225*d9e8da70SAndroid Build Coastguard Worker│    ↓ HashMap[ItemsTab]
226*d9e8da70SAndroid Build Coastguard Worker├─ com.example.Tab instance
227*d9e8da70SAndroid Build Coastguard Worker│ ...
228*d9e8da70SAndroid Build Coastguard Worker```
229*d9e8da70SAndroid Build Coastguard Worker
230*d9e8da70SAndroid Build Coastguard WorkerAnother benefit of this change is that leak signatures become less dependent of the runtime, and therefore are more consistent. This is especially true for any data structure that relies on a linked list (`HashMap`, `LinkedList`, `MessageQueue`, ...). Currently LeakCanary supports a limited set of common data structures from Apache Harmony, Open JDK, and the Android SDK. Let me know what else you need!
231*d9e8da70SAndroid Build Coastguard Worker
232*d9e8da70SAndroid Build Coastguard Worker### ObjectAnimator leaks
233*d9e8da70SAndroid Build Coastguard Worker
234*d9e8da70SAndroid Build Coastguard WorkerLeakCanary will now detect leaks that trigger when forgetting to cancel `ObjectAnimator`. This new feature is enabled by the node discovery changes described above!
235*d9e8da70SAndroid Build Coastguard Worker
236*d9e8da70SAndroid Build Coastguard WorkerLet's say you accidentally start an infinite `ObjectAnimator` and never cancel it, like so:
237*d9e8da70SAndroid Build Coastguard Worker
238*d9e8da70SAndroid Build Coastguard Worker```kotlin
239*d9e8da70SAndroid Build Coastguard Workerclass ExampleActivity : Activity() {
240*d9e8da70SAndroid Build Coastguard Worker
241*d9e8da70SAndroid Build Coastguard Worker  override fun onCreate(savedInstanceState: Bundle?) {
242*d9e8da70SAndroid Build Coastguard Worker    super.onCreate(savedInstanceState)
243*d9e8da70SAndroid Build Coastguard Worker    setContentView(R.layout.main_activity)
244*d9e8da70SAndroid Build Coastguard Worker    findViewById<Button>(R.id.button).setOnClickListener { view ->
245*d9e8da70SAndroid Build Coastguard Worker      ObjectAnimator.ofFloat(view, View.ALPHA, 0.1f, 0.2f).apply {
246*d9e8da70SAndroid Build Coastguard Worker        duration = 100
247*d9e8da70SAndroid Build Coastguard Worker        repeatMode = ValueAnimator.REVERSE
248*d9e8da70SAndroid Build Coastguard Worker        repeatCount = ValueAnimator.INFINITE
249*d9e8da70SAndroid Build Coastguard Worker        start()
250*d9e8da70SAndroid Build Coastguard Worker      }
251*d9e8da70SAndroid Build Coastguard Worker    }
252*d9e8da70SAndroid Build Coastguard Worker  }
253*d9e8da70SAndroid Build Coastguard Worker}
254*d9e8da70SAndroid Build Coastguard Worker```
255*d9e8da70SAndroid Build Coastguard Worker
256*d9e8da70SAndroid Build Coastguard WorkerIn previous releases, LeakCanary would detect that the animated view is leaking but it wouldn't be able to find the leak and instead would report it as an unreachable object: _An unreachable object is still in memory but LeakCanary could not find a strong reference path from GC roots._
257*d9e8da70SAndroid Build Coastguard Worker
258*d9e8da70SAndroid Build Coastguard WorkerLeakCanary now reports the leak and adds animator state information, helping detect and fix any infinite `ObjectAnimator`.
259*d9e8da70SAndroid Build Coastguard Worker
260*d9e8da70SAndroid Build Coastguard Worker```
261*d9e8da70SAndroid Build Coastguard Worker┬───
262*d9e8da70SAndroid Build Coastguard Worker│ GC Root: Thread object
263*d9e8da70SAndroid Build Coastguard Worker264*d9e8da70SAndroid Build Coastguard Worker├─ java.lang.Thread instance
265*d9e8da70SAndroid Build Coastguard Worker│    Leaking: NO (the main thread always runs)
266*d9e8da70SAndroid Build Coastguard Worker│    Thread name: 'main'
267*d9e8da70SAndroid Build Coastguard Worker│    ↓ Thread.threadLocals
268*d9e8da70SAndroid Build Coastguard Worker│             ~~~~~~~~~~~~
269*d9e8da70SAndroid Build Coastguard Worker...
270*d9e8da70SAndroid Build Coastguard Worker├─ android.animation.ObjectAnimator instance
271*d9e8da70SAndroid Build Coastguard Worker│    Leaking: UNKNOWN
272*d9e8da70SAndroid Build Coastguard Worker│    mListeners = null
273*d9e8da70SAndroid Build Coastguard Worker│    mPropertyName = null
274*d9e8da70SAndroid Build Coastguard WorkermProperty.mName = alpha
275*d9e8da70SAndroid Build Coastguard WorkermProperty.mType = java.lang.Float
276*d9e8da70SAndroid Build Coastguard Worker│    mInitialized = true
277*d9e8da70SAndroid Build Coastguard Worker│    mStarted = true
278*d9e8da70SAndroid Build Coastguard Worker│    mRunning = true
279*d9e8da70SAndroid Build Coastguard Worker│    mAnimationEndRequested = false
280*d9e8da70SAndroid Build Coastguard Worker│    mDuration = 100
281*d9e8da70SAndroid Build Coastguard Worker│    mStartDelay = 0
282*d9e8da70SAndroid Build Coastguard Worker│    mRepeatCount = INFINITE (-1)
283*d9e8da70SAndroid Build Coastguard Worker│    mRepeatMode = REVERSE (2)
284*d9e8da70SAndroid Build Coastguard Worker│    ↓ ObjectAnimator.mTarget
285*d9e8da70SAndroid Build Coastguard Worker│                     ~~~~~~~
286*d9e8da70SAndroid Build Coastguard Worker╰→ android.widget.Button instance
287*d9e8da70SAndroid Build Coastguard Worker     Leaking: YES (View.mContext references a destroyed activity)
288*d9e8da70SAndroid Build Coastguard Worker```
289*d9e8da70SAndroid Build Coastguard Worker
290*d9e8da70SAndroid Build Coastguard WorkerTo learn more, see this AOSP issue: [ObjectAnimator.mTarget weak ref creates memory leaks on infinite animators](https://issuetracker.google.com/issues/212993949).
291*d9e8da70SAndroid Build Coastguard Worker
292*d9e8da70SAndroid Build Coastguard Worker### Leak detection in tests
293*d9e8da70SAndroid Build Coastguard Worker
294*d9e8da70SAndroid Build Coastguard WorkerPrevious releases of `leakcanary-android-instrumentation` introduced a `FailTestOnLeakRunListener` which could run leak detection after each UI tests. Unfortunately `FailTestOnLeakRunListener` relied on a hack around `androidx.test` internals to report failures. The internals keep changing with every `androidx.test` release and breaking `FailTestOnLeakRunListener` ��.
295*d9e8da70SAndroid Build Coastguard Worker
296*d9e8da70SAndroid Build Coastguard Worker`FailTestOnLeakRunListener` is now deprecated (��) and replaced by the `DetectLeaksAfterTestSuccess` test rule, which you can add to your test like any normal test rule.
297*d9e8da70SAndroid Build Coastguard Worker
298*d9e8da70SAndroid Build Coastguard WorkerAdditionally, you can call `LeakAssertions.assertNoLeak()` from anywhere in your instrumentation tests. You can also annotate tests with `@SkipLeakDetection` (for that to work you'll also need to set up the `TestDescriptionHolder` test rule).
299*d9e8da70SAndroid Build Coastguard Worker
300*d9e8da70SAndroid Build Coastguard Worker```kotlin
301*d9e8da70SAndroid Build Coastguard Workerclass CartTest {
302*d9e8da70SAndroid Build Coastguard Worker  @get:Rule
303*d9e8da70SAndroid Build Coastguard Worker  val rules = RuleChain.outerRule(TestDescriptionHolder)
304*d9e8da70SAndroid Build Coastguard Worker    .around(DetectLeaksAfterTestSuccess())
305*d9e8da70SAndroid Build Coastguard Worker    .around(ActivityScenarioRule(CartActivity::class.java))
306*d9e8da70SAndroid Build Coastguard Worker
307*d9e8da70SAndroid Build Coastguard Worker  @Test
308*d9e8da70SAndroid Build Coastguard Worker  fun addItemToCart() {
309*d9e8da70SAndroid Build Coastguard Worker    // ...
310*d9e8da70SAndroid Build Coastguard Worker  }
311*d9e8da70SAndroid Build Coastguard Worker
312*d9e8da70SAndroid Build Coastguard Worker  @SkipLeakDetection("See #1234")
313*d9e8da70SAndroid Build Coastguard Worker  @Test
314*d9e8da70SAndroid Build Coastguard Worker  fun removeItemFromCart() {
315*d9e8da70SAndroid Build Coastguard Worker    // ...
316*d9e8da70SAndroid Build Coastguard Worker  }
317*d9e8da70SAndroid Build Coastguard Worker}
318*d9e8da70SAndroid Build Coastguard Worker```
319*d9e8da70SAndroid Build Coastguard Worker
320*d9e8da70SAndroid Build Coastguard Worker### Android 12
321*d9e8da70SAndroid Build Coastguard Worker
322*d9e8da70SAndroid Build Coastguard WorkerHopefully this time we fixed everything that Android 12 broke: missing `exported:true` tags, missing pending intent flags, and `ForegroundServiceStartNotAllowedException` crashes. If not, let us know! Can't wait for Android 13 to break everything again ��.
323*d9e8da70SAndroid Build Coastguard Worker
324*d9e8da70SAndroid Build Coastguard Worker### WorkManager
325*d9e8da70SAndroid Build Coastguard Worker
326*d9e8da70SAndroid Build Coastguard WorkerRunning an Android Service without crashing (`ForegroundServiceStartNotAllowedException`...) is becoming harder with every release of Android, so I got rid of the LeakCanary heap analyzer service! Instead, LeakCanary leverages WorkManager if you already have it as a dependency. If you don't use WorkManager, then LeakCanary will fall back to using a simple thread.
327*d9e8da70SAndroid Build Coastguard Worker
328*d9e8da70SAndroid Build Coastguard WorkerNote: I recommend using at least [WorkManager 2.7.0](https://developer.android.com/jetpack/androidx/releases/work#2.7.0) as it adds the `WorkRequest.Builder.setExpedited()` API which LeakCanary leverages if available.
329*d9e8da70SAndroid Build Coastguard Worker
330*d9e8da70SAndroid Build Coastguard Worker### Multi process
331*d9e8da70SAndroid Build Coastguard Worker
332*d9e8da70SAndroid Build Coastguard WorkerSwitching to WorkManager also impacts the LeakCanary multi process approach, which now leverages WorkManager remote jobs. Blog on how I got this working: [WorkManager multi-process for libraries](https://py.hashnode.dev/workmanager-multi-process-for-libraries).
333*d9e8da70SAndroid Build Coastguard Worker
334*d9e8da70SAndroid Build Coastguard WorkerMulti process is harder to get right so you should only use this if LeakCanary frequently runs out of memory while performing the heap analysis. Here are the updated set up steps:
335*d9e8da70SAndroid Build Coastguard Worker
336*d9e8da70SAndroid Build Coastguard Worker1) Add the `leakcanary-android-process` dependency and **keep the `leakcanary-android` dependency**.
337*d9e8da70SAndroid Build Coastguard Worker
338*d9e8da70SAndroid Build Coastguard Worker```groovy
339*d9e8da70SAndroid Build Coastguard Workerdependencies {
340*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8'
341*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android-process:2.8'
342*d9e8da70SAndroid Build Coastguard Worker}
343*d9e8da70SAndroid Build Coastguard Worker```
344*d9e8da70SAndroid Build Coastguard Worker
345*d9e8da70SAndroid Build Coastguard Worker2) Skip the initialization code in the `Application` class
346*d9e8da70SAndroid Build Coastguard Worker
347*d9e8da70SAndroid Build Coastguard Worker```kotlin
348*d9e8da70SAndroid Build Coastguard Workerclass ExampleApplication : Application() {
349*d9e8da70SAndroid Build Coastguard Worker
350*d9e8da70SAndroid Build Coastguard Worker  override fun onCreate() {
351*d9e8da70SAndroid Build Coastguard Worker    if (LeakCanaryProcess.isInAnalyzerProcess(this)) {
352*d9e8da70SAndroid Build Coastguard Worker      return
353*d9e8da70SAndroid Build Coastguard Worker    }
354*d9e8da70SAndroid Build Coastguard Worker    super.onCreate()
355*d9e8da70SAndroid Build Coastguard Worker    // normal init goes here, skipped in :leakcanary process.
356*d9e8da70SAndroid Build Coastguard Worker  }
357*d9e8da70SAndroid Build Coastguard Worker}
358*d9e8da70SAndroid Build Coastguard Worker```
359*d9e8da70SAndroid Build Coastguard Worker
360*d9e8da70SAndroid Build Coastguard WorkerThat's it! Note that event listeners (see below) related to the analysis will fire in the remote process.
361*d9e8da70SAndroid Build Coastguard Worker
362*d9e8da70SAndroid Build Coastguard Worker### AndroidX App Startup
363*d9e8da70SAndroid Build Coastguard Worker
364*d9e8da70SAndroid Build Coastguard WorkerLeakCanary now optionally supports the [AndroidX App Startup library](https://developer.android.com/topic/libraries/app-startup). All you need to do is replace the `leakcanary-android` dependency with `leakcanary-android-startup`:
365*d9e8da70SAndroid Build Coastguard Worker
366*d9e8da70SAndroid Build Coastguard Worker```groovy
367*d9e8da70SAndroid Build Coastguard Workerdependencies {
368*d9e8da70SAndroid Build Coastguard Worker  // Remove the normal leakcanary-android dependency
369*d9e8da70SAndroid Build Coastguard Worker  // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8'
370*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android-startup:2.8'
371*d9e8da70SAndroid Build Coastguard Worker}
372*d9e8da70SAndroid Build Coastguard Worker```
373*d9e8da70SAndroid Build Coastguard Worker
374*d9e8da70SAndroid Build Coastguard WorkerNote 1: `leakcanary-android` adds the code for automatic installl to `leakcanary-android-core`. If you're calling `AppWatcher.manualInstall()`, you can depend directly on `leakcanary-android-core` instead of `leakcanary-android`, and you won't need the disable any automatic install.
375*d9e8da70SAndroid Build Coastguard Worker
376*d9e8da70SAndroid Build Coastguard WorkerNote 2: the same principle applies to `leakcanary-object-watcher-android`: it depends on `leakcanary-object-watcher-android-core` and adds automatic install, while `leakcanary-object-watcher-android-startup` leverages the App Startup library. Same for `plumber-android`, `plumber-android-core` and  `plumber-android-startup`.
377*d9e8da70SAndroid Build Coastguard Worker
378*d9e8da70SAndroid Build Coastguard Worker### Event listeners
379*d9e8da70SAndroid Build Coastguard Worker
380*d9e8da70SAndroid Build Coastguard Worker`LeakCanary.Config` has a new `eventListeners` field allowing you to react to LeakCanary's lifecycle. If you want to customize this, you most likely should be keeping the default list of listeners and add or remove from it.
381*d9e8da70SAndroid Build Coastguard Worker
382*d9e8da70SAndroid Build Coastguard WorkerFor example, if you want to disable the LeakCanary toast:
383*d9e8da70SAndroid Build Coastguard Worker
384*d9e8da70SAndroid Build Coastguard Worker```kotlin
385*d9e8da70SAndroid Build Coastguard WorkerLeakCanary.config = LeakCanary.config.run {
386*d9e8da70SAndroid Build Coastguard Worker  copy(
387*d9e8da70SAndroid Build Coastguard Worker    eventListeners = eventListeners.filter {
388*d9e8da70SAndroid Build Coastguard Worker      it !is ToastEventListener
389*d9e8da70SAndroid Build Coastguard Worker    }
390*d9e8da70SAndroid Build Coastguard Worker  )
391*d9e8da70SAndroid Build Coastguard Worker}
392*d9e8da70SAndroid Build Coastguard Worker```
393*d9e8da70SAndroid Build Coastguard Worker
394*d9e8da70SAndroid Build Coastguard WorkerIf you want to upload heap analysis results:
395*d9e8da70SAndroid Build Coastguard Worker
396*d9e8da70SAndroid Build Coastguard Worker```kotlin
397*d9e8da70SAndroid Build Coastguard WorkerLeakCanary.config = LeakCanary.config.run {
398*d9e8da70SAndroid Build Coastguard Worker  copy(
399*d9e8da70SAndroid Build Coastguard Worker    eventListeners = eventListeners + EventListener { event ->
400*d9e8da70SAndroid Build Coastguard Worker      if (event is HeapAnalysisSucceeded) {
401*d9e8da70SAndroid Build Coastguard Worker        // Upload event.heapAnalysis
402*d9e8da70SAndroid Build Coastguard Worker      }
403*d9e8da70SAndroid Build Coastguard Worker    }
404*d9e8da70SAndroid Build Coastguard Worker  )
405*d9e8da70SAndroid Build Coastguard Worker}
406*d9e8da70SAndroid Build Coastguard Worker```
407*d9e8da70SAndroid Build Coastguard Worker
408*d9e8da70SAndroid Build Coastguard WorkerNote: `Leakcanary.Config.onHeapAnalyzedListener` still works but is now deprecated.
409*d9e8da70SAndroid Build Coastguard Worker
410*d9e8da70SAndroid Build Coastguard WorkerFeedback welcome on this new API!
411*d9e8da70SAndroid Build Coastguard Worker
412*d9e8da70SAndroid Build Coastguard Worker### Other bug fixes and improvements ����
413*d9e8da70SAndroid Build Coastguard Worker
414*d9e8da70SAndroid Build Coastguard Worker* [#2096](https://github.com/square/leakcanary/issues/2096) Opening / sharing heap dump files now supports LeakCanary as an option.
415*d9e8da70SAndroid Build Coastguard Worker* [#2210](https://github.com/square/leakcanary/issues/2210) First Compose dedicated object inspectors!
416*d9e8da70SAndroid Build Coastguard Worker* [#2121](https://github.com/square/leakcanary/pull/2121) Support for customizing the heap dumper.
417*d9e8da70SAndroid Build Coastguard Worker
418*d9e8da70SAndroid Build Coastguard WorkerThis list reflects only a subset of all changes. For more details, see the [2.8 Milestone](https://github.com/square/leakcanary/milestone/22) and the [full diff](https://github.com/square/leakcanary/compare/v2.7...v2.8).
419*d9e8da70SAndroid Build Coastguard Worker
420*d9e8da70SAndroid Build Coastguard Worker
421*d9e8da70SAndroid Build Coastguard Worker## Version 2.7 (2021-03-26)
422*d9e8da70SAndroid Build Coastguard Worker
423*d9e8da70SAndroid Build Coastguard WorkerPlease thank
424*d9e8da70SAndroid Build Coastguard Worker[@chao2zhang](https://github.com/chao2zhang),
425*d9e8da70SAndroid Build Coastguard Worker[@ihrupin](https://github.com/ihrupin),
426*d9e8da70SAndroid Build Coastguard Worker[@jzbrooks](https://github.com/jzbrooks),
427*d9e8da70SAndroid Build Coastguard Worker[@msfjarvis](https://github.com/msfjarvis),
428*d9e8da70SAndroid Build Coastguard Worker[@reneargento](https://github.com/reneargento),
429*d9e8da70SAndroid Build Coastguard Worker[@Unpublished](https://github.com/Unpublished)
430*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests �� �� ��.
431*d9e8da70SAndroid Build Coastguard Worker
432*d9e8da70SAndroid Build Coastguard Worker### Finer grained root view watching
433*d9e8da70SAndroid Build Coastguard Worker
434*d9e8da70SAndroid Build Coastguard WorkerIn version 2.6, LeakCanary added detection of root views retained after  `View.onDetachedFromWindow()`. This helps find more leaks, but unfortunately some Android widgets keep a detached root view around to reattach it later (e.g. spinner). App developers also sometimes do the same with dialogs, keeping a single instance around and calling `show()` and `hide()` as needed. As a result, LeakCanary would report leaks that were actually not leaks.
435*d9e8da70SAndroid Build Coastguard Worker
436*d9e8da70SAndroid Build Coastguard WorkerIn version 2.7, the default behavior changed: LeakCanary will continue to detect leaks of toasts, but will ignore root views created by a PopupWindow (which is what Android widgets use). It will also ignore root views created by a dialog by default, and you can turn this back on by setting the `leak_canary_watcher_watch_dismissed_dialogs` resource boolean to true:
437*d9e8da70SAndroid Build Coastguard Worker
438*d9e8da70SAndroid Build Coastguard Worker
439*d9e8da70SAndroid Build Coastguard Worker```xml
440*d9e8da70SAndroid Build Coastguard Worker<?xml version="1.0" encoding="utf-8"?>
441*d9e8da70SAndroid Build Coastguard Worker<resources>
442*d9e8da70SAndroid Build Coastguard Worker  <bool name="leak_canary_watcher_watch_dismissed_dialogs">true</bool>
443*d9e8da70SAndroid Build Coastguard Worker</resources>
444*d9e8da70SAndroid Build Coastguard Worker```
445*d9e8da70SAndroid Build Coastguard Worker
446*d9e8da70SAndroid Build Coastguard WorkerThis is implemented using a new Square library: [Curtains](https://github.com/square/curtains).
447*d9e8da70SAndroid Build Coastguard Worker
448*d9e8da70SAndroid Build Coastguard Worker### Targeting Android 12
449*d9e8da70SAndroid Build Coastguard Worker
450*d9e8da70SAndroid Build Coastguard WorkerWe fixed two issues for apps that want to target Android 12:
451*d9e8da70SAndroid Build Coastguard Worker
452*d9e8da70SAndroid Build Coastguard Worker* [#2074](https://github.com/square/leakcanary/pull/2074) Activities that use intent filters must declare the `android:exported` attribute.
453*d9e8da70SAndroid Build Coastguard Worker* [#2079](https://github.com/square/leakcanary/issues/2079) PendingIntent requires the `FLAG_IMMUTABLE` flag.
454*d9e8da70SAndroid Build Coastguard Worker
455*d9e8da70SAndroid Build Coastguard Worker### Bug fixes and improvements ����
456*d9e8da70SAndroid Build Coastguard Worker
457*d9e8da70SAndroid Build Coastguard Worker* [#2075](https://github.com/square/leakcanary/issues/2075) Fixed crash when sharing heap dumps.
458*d9e8da70SAndroid Build Coastguard Worker* [#2067](https://github.com/square/leakcanary/issues/2067) Fixed crash when opening leaks from older versions (before 2.6) of LeakCanary.
459*d9e8da70SAndroid Build Coastguard Worker* [#2049](https://github.com/square/leakcanary/issues/2049) Fixed Plumber crash due to R8 shaking AndroidLeakFixes.
460*d9e8da70SAndroid Build Coastguard Worker* [#2084](https://github.com/square/leakcanary/issues/2084) Fixed Shark crash when used from multiple threads.
461*d9e8da70SAndroid Build Coastguard Worker* [#2054](https://github.com/square/leakcanary/issues/2054) ������ Blocked Monkeys from deleting leaks.
462*d9e8da70SAndroid Build Coastguard Worker* [#2069](https://github.com/square/leakcanary/issues/2069) Added X button to the root leak activity (for custom devices with no back button)
463*d9e8da70SAndroid Build Coastguard Worker* [#2091](https://github.com/square/leakcanary/issues/2091) Added receiver details if LoadedApk shows up in the leaktrace.
464*d9e8da70SAndroid Build Coastguard Worker* [#2083](https://github.com/square/leakcanary/issues/2083) Added service status details (created or not) to leaktrace.
465*d9e8da70SAndroid Build Coastguard Worker* [#2099](https://github.com/square/leakcanary/pull/2099) Retry button if analysis fails.
466*d9e8da70SAndroid Build Coastguard Worker* [#2066](https://github.com/square/leakcanary/pull/2066) When heap analysis in UI tests is skipped and NoAnalysis is returned, NoAnalysis now includes a reason to help debug why it didn't run.
467*d9e8da70SAndroid Build Coastguard Worker* [#2000](https://github.com/square/leakcanary/issues/2000) The LeakCanary CI now leverages GitHub actions instead of Travis.
468*d9e8da70SAndroid Build Coastguard Worker
469*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.7 Milestone](https://github.com/square/leakcanary/milestone/21) and the [full diff](https://github.com/square/leakcanary/compare/v2.6...v2.7).
470*d9e8da70SAndroid Build Coastguard Worker
471*d9e8da70SAndroid Build Coastguard Worker##  Version 2.6 - Christmas Release �� (2020-12-24)
472*d9e8da70SAndroid Build Coastguard Worker
473*d9e8da70SAndroid Build Coastguard WorkerPlease thank
474*d9e8da70SAndroid Build Coastguard Worker[@chao2zhang](https://github.com/chao2zhang),
475*d9e8da70SAndroid Build Coastguard Worker[@ChaosLeung](https://github.com/ChaosLeung),
476*d9e8da70SAndroid Build Coastguard Worker[@LitterSun](https://github.com/LitterSun),
477*d9e8da70SAndroid Build Coastguard Worker[@mickverm](https://github.com/mickverm),
478*d9e8da70SAndroid Build Coastguard Worker[@opatry](https://github.com/opatry),
479*d9e8da70SAndroid Build Coastguard Worker[@Thomas-Vos](https://github.com/Thomas-Vos),
480*d9e8da70SAndroid Build Coastguard Worker[@tricknology](https://github.com/tricknology),
481*d9e8da70SAndroid Build Coastguard Worker[@rahul-a](https://github.com/rahul-a),
482*d9e8da70SAndroid Build Coastguard Worker[@samoylenkodmitry](https://github.com/samoylenkodmitry),
483*d9e8da70SAndroid Build Coastguard Worker[@sing0055](https://github.com/sing0055),
484*d9e8da70SAndroid Build Coastguard Worker[@ubiratansoares](https://github.com/ubiratansoares)
485*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests �� �� ��.
486*d9e8da70SAndroid Build Coastguard Worker
487*d9e8da70SAndroid Build Coastguard WorkerThis Christmas Release includes several external contributions and a bunch of cool new features! ����
488*d9e8da70SAndroid Build Coastguard Worker
489*d9e8da70SAndroid Build Coastguard Worker###  Detecting root views retained after `View.onDetachedFromWindow()`
490*d9e8da70SAndroid Build Coastguard Worker
491*d9e8da70SAndroid Build Coastguard WorkerOn Android, every displayed view hierarchy is attached to a window, whether it be the view hierarchy of an activity, a dialog, a toast or [a chat head](http://www.piwai.info/chatheads-basics). After a view hierarchy is detached from its window, it should be garbage collected.
492*d9e8da70SAndroid Build Coastguard Worker
493*d9e8da70SAndroid Build Coastguard WorkerLeakCanary already detects leaks of activity view hierarchies because retained detached views reference their activity context and LeakCanary detects activities retained after `Activity.onDestroy()`. In this new release, LeakCanary will now detect the leak of a dialog view hierarchy as soon as that dialog is dismissed, or any other view that is passed to [WindowManager.removeView()](https://developer.android.com/reference/android/view/ViewManager#removeView(android.view.View)).
494*d9e8da70SAndroid Build Coastguard Worker
495*d9e8da70SAndroid Build Coastguard Worker###  Detecting services retained after `Service.onDestroy()`
496*d9e8da70SAndroid Build Coastguard Worker
497*d9e8da70SAndroid Build Coastguard WorkerAfter an Android [service](https://developer.android.com/reference/android/app/Service) is destroyed, it should be garbage collected. Unfortunately, the Android SDK does not provide any generic API to observe the service lifecycle. We worked around that using reflection on greylist APIs (details in [#2014](https://github.com/square/leakcanary/pull/2014)). Let's hope this motivates the Android team to [build the APIs developers need](https://twitter.com/Piwai/status/1342029560116891648).
498*d9e8da70SAndroid Build Coastguard Worker
499*d9e8da70SAndroid Build Coastguard Worker### Configuring retained object detection
500*d9e8da70SAndroid Build Coastguard Worker
501*d9e8da70SAndroid Build Coastguard WorkerWith the detection of 2 new types of retained objects, we're also adding APIs to configure which _watchers_ should be installed as well as adding filtering capabilities.
502*d9e8da70SAndroid Build Coastguard Worker
503*d9e8da70SAndroid Build Coastguard WorkerFirst, disable the automatic install:
504*d9e8da70SAndroid Build Coastguard Worker
505*d9e8da70SAndroid Build Coastguard Worker```xml
506*d9e8da70SAndroid Build Coastguard Worker<?xml version="1.0" encoding="utf-8"?>
507*d9e8da70SAndroid Build Coastguard Worker<resources>
508*d9e8da70SAndroid Build Coastguard Worker  <bool name="leak_canary_watcher_auto_install">false</bool>
509*d9e8da70SAndroid Build Coastguard Worker</resources>
510*d9e8da70SAndroid Build Coastguard Worker```
511*d9e8da70SAndroid Build Coastguard Worker
512*d9e8da70SAndroid Build Coastguard WorkerThen you can install LeakCanary manually. LeakCanary 2.6 comes with 4 watchers installed by default: `ActivityWatcher`, `FragmentAndViewModelWatcher`, `RootViewWatcher`, `ServiceWatcher`. Here's an example to get all the default watchers except `ServiceWatcher`:
513*d9e8da70SAndroid Build Coastguard Worker
514*d9e8da70SAndroid Build Coastguard Worker```kotlin
515*d9e8da70SAndroid Build Coastguard Workerclass DebugExampleApplication : ExampleApplication() {
516*d9e8da70SAndroid Build Coastguard Worker
517*d9e8da70SAndroid Build Coastguard Worker  override fun onCreate() {
518*d9e8da70SAndroid Build Coastguard Worker    super.onCreate()
519*d9e8da70SAndroid Build Coastguard Worker
520*d9e8da70SAndroid Build Coastguard Worker    val watchersToInstall = AppWatcher.appDefaultWatchers(application)
521*d9e8da70SAndroid Build Coastguard Worker      .filter { it !is ServiceWatcher }
522*d9e8da70SAndroid Build Coastguard Worker
523*d9e8da70SAndroid Build Coastguard Worker    AppWatcher.manualInstall(
524*d9e8da70SAndroid Build Coastguard Worker      application = application,
525*d9e8da70SAndroid Build Coastguard Worker      watchersToInstall = watchersToInstall
526*d9e8da70SAndroid Build Coastguard Worker    )
527*d9e8da70SAndroid Build Coastguard Worker  }
528*d9e8da70SAndroid Build Coastguard Worker}
529*d9e8da70SAndroid Build Coastguard Worker```
530*d9e8da70SAndroid Build Coastguard Worker
531*d9e8da70SAndroid Build Coastguard WorkerLeakCanary introduces a new functional (SAM) interface implemented by `ObjectWatcher`: `ReachabilityWatcher`, with a `ReachabilityWatcher.expectWeaklyReachable()` method that replaces the now deprecated `ObjectWatcher.watch()` method. You can create the default watcher instances with a custom `ReachabilityWatcher` that delegates to `AppWatcher.objectWatcher` but filters out specific instances (e.g. `BadSdkLeakingFragment`):
532*d9e8da70SAndroid Build Coastguard Worker
533*d9e8da70SAndroid Build Coastguard Worker```kotlin
534*d9e8da70SAndroid Build Coastguard Workerclass DebugExampleApplication : ExampleApplication() {
535*d9e8da70SAndroid Build Coastguard Worker
536*d9e8da70SAndroid Build Coastguard Worker  override fun onCreate() {
537*d9e8da70SAndroid Build Coastguard Worker    super.onCreate()
538*d9e8da70SAndroid Build Coastguard Worker
539*d9e8da70SAndroid Build Coastguard Worker    val delegate = ReachabilityWatcher { watchedObject, description ->
540*d9e8da70SAndroid Build Coastguard Worker      if (watchedObject !is BadSdkLeakingFragment) {
541*d9e8da70SAndroid Build Coastguard Worker        AppWatcher.objectWatcher.expectWeaklyReachable(watchedObject, description)
542*d9e8da70SAndroid Build Coastguard Worker      }
543*d9e8da70SAndroid Build Coastguard Worker    }
544*d9e8da70SAndroid Build Coastguard Worker
545*d9e8da70SAndroid Build Coastguard Worker    val watchersToInstall = AppWatcher.appDefaultWatchers(application, delegate)
546*d9e8da70SAndroid Build Coastguard Worker
547*d9e8da70SAndroid Build Coastguard Worker    AppWatcher.manualInstall(
548*d9e8da70SAndroid Build Coastguard Worker      application = application,
549*d9e8da70SAndroid Build Coastguard Worker      watchersToInstall = watchersToInstall
550*d9e8da70SAndroid Build Coastguard Worker    )
551*d9e8da70SAndroid Build Coastguard Worker  }
552*d9e8da70SAndroid Build Coastguard Worker}
553*d9e8da70SAndroid Build Coastguard Worker```
554*d9e8da70SAndroid Build Coastguard Worker
555*d9e8da70SAndroid Build Coastguard WorkerWith these new configuration options, `AppWatcher.config` is now deprecated and a no-op.
556*d9e8da70SAndroid Build Coastguard Worker
557*d9e8da70SAndroid Build Coastguard Worker### Dumping the heap on screen off
558*d9e8da70SAndroid Build Coastguard Worker
559*d9e8da70SAndroid Build Coastguard WorkerThe default threshold to dump the heap is **5 retained objects** when the app is **visible**, and **1 retained object** when the app is **not visible**. Up until now, visible meant "the app has at least one activity in **started** state". In LeakCanary 2.6, the app will now be considered **not visible** if the device screen is **off**, lowering the threshold to trigger heap dumps when you turn off the device screen.
560*d9e8da70SAndroid Build Coastguard Worker
561*d9e8da70SAndroid Build Coastguard Worker### LeakCanary for releases
562*d9e8da70SAndroid Build Coastguard Worker
563*d9e8da70SAndroid Build Coastguard WorkerLeakCanary 2.6 introduces a new artifact: `leakcanary-android-release`. This artifact exposes APIs to run a heap analysis in release builds, in production.
564*d9e8da70SAndroid Build Coastguard Worker
565*d9e8da70SAndroid Build Coastguard Worker!!! danger
566*d9e8da70SAndroid Build Coastguard Worker    Everything about this is experimental. Running a heap analysis in production is not a very common thing to do, and we're still learning and experimenting with this. Also, both the artifact name and the APIs may change.
567*d9e8da70SAndroid Build Coastguard Worker
568*d9e8da70SAndroid Build Coastguard Worker```groovy
569*d9e8da70SAndroid Build Coastguard Workerdependencies {
570*d9e8da70SAndroid Build Coastguard Worker  // debugImplementation because LeakCanary should only run in debug builds.
571*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
572*d9e8da70SAndroid Build Coastguard Worker
573*d9e8da70SAndroid Build Coastguard Worker  // NEW: LeakCanary for releases!
574*d9e8da70SAndroid Build Coastguard Worker  releaseImplementation 'com.squareup.leakcanary:leakcanary-android-release:2.6'
575*d9e8da70SAndroid Build Coastguard Worker  // Optional: detect retained objects. This helps but is not required.
576*d9e8da70SAndroid Build Coastguard Worker  releaseImplementation 'com.squareup.leakcanary:leakcanary-object-watcher-android:2.6'
577*d9e8da70SAndroid Build Coastguard Worker}
578*d9e8da70SAndroid Build Coastguard Worker```
579*d9e8da70SAndroid Build Coastguard Worker
580*d9e8da70SAndroid Build Coastguard WorkerHere's a code example that runs a heap analysis when the screen is turned off or the app enters background, checking first if a [Firebase Remote Config](https://firebase.google.com/products/remote-config) flag is turned on, and uploading the result to Bugsnag:
581*d9e8da70SAndroid Build Coastguard Worker
582*d9e8da70SAndroid Build Coastguard Worker
583*d9e8da70SAndroid Build Coastguard Worker```kotlin
584*d9e8da70SAndroid Build Coastguard Workerclass ReleaseExampleApplication : ExampleApplication() {
585*d9e8da70SAndroid Build Coastguard Worker
586*d9e8da70SAndroid Build Coastguard Worker  // Cancels heap analysis if "heap_analysis_flag" is false.
587*d9e8da70SAndroid Build Coastguard Worker  private val flagInterceptor by lazy {
588*d9e8da70SAndroid Build Coastguard Worker    object : HeapAnalysisInterceptor {
589*d9e8da70SAndroid Build Coastguard Worker
590*d9e8da70SAndroid Build Coastguard Worker      val remoteConfig: FirebaseRemoteConfig = TODO()
591*d9e8da70SAndroid Build Coastguard Worker
592*d9e8da70SAndroid Build Coastguard Worker      override fun intercept(chain: Chain): HeapAnalysisJob.Result {
593*d9e8da70SAndroid Build Coastguard Worker        if (remoteConfig.getBoolean("heap_analysis_flag")) {
594*d9e8da70SAndroid Build Coastguard Worker          chain.job.cancel("heap_analysis_flag false")
595*d9e8da70SAndroid Build Coastguard Worker        }
596*d9e8da70SAndroid Build Coastguard Worker        return chain.proceed()
597*d9e8da70SAndroid Build Coastguard Worker      }
598*d9e8da70SAndroid Build Coastguard Worker    }
599*d9e8da70SAndroid Build Coastguard Worker  }
600*d9e8da70SAndroid Build Coastguard Worker
601*d9e8da70SAndroid Build Coastguard Worker  private val analysisClient by lazy {
602*d9e8da70SAndroid Build Coastguard Worker    HeapAnalysisClient(
603*d9e8da70SAndroid Build Coastguard Worker      // Use private app storage. cacheDir is never backed up which is important.
604*d9e8da70SAndroid Build Coastguard Worker      heapDumpDirectoryProvider = { cacheDir },
605*d9e8da70SAndroid Build Coastguard Worker      // stripHeapDump: remove all user data from hprof before analysis.
606*d9e8da70SAndroid Build Coastguard Worker      config = HeapAnalysisConfig(stripHeapDump = true),
607*d9e8da70SAndroid Build Coastguard Worker      // Default interceptors may cancel analysis for several other reasons.
608*d9e8da70SAndroid Build Coastguard Worker      interceptors = listOf(flagInterceptor) + HeapAnalysisClient.defaultInterceptors(this)
609*d9e8da70SAndroid Build Coastguard Worker    )
610*d9e8da70SAndroid Build Coastguard Worker  }
611*d9e8da70SAndroid Build Coastguard Worker
612*d9e8da70SAndroid Build Coastguard Worker  private val analysisExecutor by lazy {
613*d9e8da70SAndroid Build Coastguard Worker    Executors.newSingleThreadExecutor {
614*d9e8da70SAndroid Build Coastguard Worker      thread(start = false, name = "Heap analysis executor") {
615*d9e8da70SAndroid Build Coastguard Worker        android.os.Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND)
616*d9e8da70SAndroid Build Coastguard Worker        it.run()
617*d9e8da70SAndroid Build Coastguard Worker      }
618*d9e8da70SAndroid Build Coastguard Worker    }
619*d9e8da70SAndroid Build Coastguard Worker  }
620*d9e8da70SAndroid Build Coastguard Worker
621*d9e8da70SAndroid Build Coastguard Worker  private val analysisCallback: (Result) -> Unit by lazy {
622*d9e8da70SAndroid Build Coastguard Worker    val uploader = BugsnagHeapAnalysisUploader(this@ReleaseExampleApplication)
623*d9e8da70SAndroid Build Coastguard Worker    { result ->
624*d9e8da70SAndroid Build Coastguard Worker      if (result is Done) {
625*d9e8da70SAndroid Build Coastguard Worker        uploader.upload(result.analysis)
626*d9e8da70SAndroid Build Coastguard Worker	  }
627*d9e8da70SAndroid Build Coastguard Worker    }
628*d9e8da70SAndroid Build Coastguard Worker  }
629*d9e8da70SAndroid Build Coastguard Worker
630*d9e8da70SAndroid Build Coastguard Worker  override fun onCreate() {
631*d9e8da70SAndroid Build Coastguard Worker    super.onCreate()
632*d9e8da70SAndroid Build Coastguard Worker
633*d9e8da70SAndroid Build Coastguard Worker    // Delete any remaining heap dump (if we crashed)
634*d9e8da70SAndroid Build Coastguard Worker    analysisExecutor.execute {
635*d9e8da70SAndroid Build Coastguard Worker      analysisClient.deleteHeapDumpFiles()
636*d9e8da70SAndroid Build Coastguard Worker    }
637*d9e8da70SAndroid Build Coastguard Worker
638*d9e8da70SAndroid Build Coastguard Worker    // Starts heap analysis on background importance
639*d9e8da70SAndroid Build Coastguard Worker    BackgroundTrigger(
640*d9e8da70SAndroid Build Coastguard Worker      application = this,
641*d9e8da70SAndroid Build Coastguard Worker      analysisClient = analysisClient,
642*d9e8da70SAndroid Build Coastguard Worker      analysisExecutor = analysisExecutor,
643*d9e8da70SAndroid Build Coastguard Worker      analysisCallback = analysisCallback
644*d9e8da70SAndroid Build Coastguard Worker    ).start()
645*d9e8da70SAndroid Build Coastguard Worker
646*d9e8da70SAndroid Build Coastguard Worker    // Starts heap analysis when screen off
647*d9e8da70SAndroid Build Coastguard Worker    ScreenOffTrigger(
648*d9e8da70SAndroid Build Coastguard Worker      application = this,
649*d9e8da70SAndroid Build Coastguard Worker      analysisClient = analysisClient,
650*d9e8da70SAndroid Build Coastguard Worker      analysisExecutor = analysisExecutor,
651*d9e8da70SAndroid Build Coastguard Worker      analysisCallback = analysisCallback
652*d9e8da70SAndroid Build Coastguard Worker    ).start()
653*d9e8da70SAndroid Build Coastguard Worker  }
654*d9e8da70SAndroid Build Coastguard Worker
655*d9e8da70SAndroid Build Coastguard Worker  /**
656*d9e8da70SAndroid Build Coastguard Worker   * Call this to trigger heap analysis manually, e.g. from
657*d9e8da70SAndroid Build Coastguard Worker   * a help button.
658*d9e8da70SAndroid Build Coastguard Worker   *
659*d9e8da70SAndroid Build Coastguard Worker   * This method returns a `HeapAnalysisJob` on which you can
660*d9e8da70SAndroid Build Coastguard Worker   * call `HeapAnalysisJob.cancel()` at any time.
661*d9e8da70SAndroid Build Coastguard Worker   */
662*d9e8da70SAndroid Build Coastguard Worker  fun triggerHeapAnalysisNow(): HeapAnalysisJob {
663*d9e8da70SAndroid Build Coastguard Worker    val job = analysisClient.newJob()
664*d9e8da70SAndroid Build Coastguard Worker    analysisExecutor.execute {
665*d9e8da70SAndroid Build Coastguard Worker      val result = job.execute()
666*d9e8da70SAndroid Build Coastguard Worker      analysisCallback(result)
667*d9e8da70SAndroid Build Coastguard Worker    }
668*d9e8da70SAndroid Build Coastguard Worker    return job
669*d9e8da70SAndroid Build Coastguard Worker  }
670*d9e8da70SAndroid Build Coastguard Worker}
671*d9e8da70SAndroid Build Coastguard Worker```
672*d9e8da70SAndroid Build Coastguard Worker
673*d9e8da70SAndroid Build Coastguard WorkerThe Bugsnag uploader:
674*d9e8da70SAndroid Build Coastguard Worker
675*d9e8da70SAndroid Build Coastguard Worker```kotlin
676*d9e8da70SAndroid Build Coastguard Workerclass BugsnagHeapAnalysisUploader(applicationContext: Application) {
677*d9e8da70SAndroid Build Coastguard Worker
678*d9e8da70SAndroid Build Coastguard Worker  private val bugsnagClient: Client
679*d9e8da70SAndroid Build Coastguard Worker
680*d9e8da70SAndroid Build Coastguard Worker  init {
681*d9e8da70SAndroid Build Coastguard Worker    bugsnagClient = Client(
682*d9e8da70SAndroid Build Coastguard Worker      applicationContext,
683*d9e8da70SAndroid Build Coastguard Worker      BUGSNAG_API_KEY,
684*d9e8da70SAndroid Build Coastguard Worker      DO_NOT_ENABLE_EXCEPTION_HANDLER
685*d9e8da70SAndroid Build Coastguard Worker    )
686*d9e8da70SAndroid Build Coastguard Worker    bugsnagClient.setSendThreads(false)
687*d9e8da70SAndroid Build Coastguard Worker  }
688*d9e8da70SAndroid Build Coastguard Worker
689*d9e8da70SAndroid Build Coastguard Worker  fun upload(heapAnalysis: HeapAnalysis) {
690*d9e8da70SAndroid Build Coastguard Worker    when (heapAnalysis) {
691*d9e8da70SAndroid Build Coastguard Worker      is HeapAnalysisSuccess -> {
692*d9e8da70SAndroid Build Coastguard Worker        val exception = HeapAnalysisReport()
693*d9e8da70SAndroid Build Coastguard Worker        bugsnagClient.notify(exception) { report ->
694*d9e8da70SAndroid Build Coastguard Worker          val metaData = report.error.metaData
695*d9e8da70SAndroid Build Coastguard Worker          metaData.addToTab("Heap Analysis", "result", heapAnalysis.toString())
696*d9e8da70SAndroid Build Coastguard Worker        }
697*d9e8da70SAndroid Build Coastguard Worker      }
698*d9e8da70SAndroid Build Coastguard Worker      is HeapAnalysisFailure -> {
699*d9e8da70SAndroid Build Coastguard Worker        // Please file any reported failure to
700*d9e8da70SAndroid Build Coastguard Worker        // https://github.com/square/leakcanary/issues
701*d9e8da70SAndroid Build Coastguard Worker        bugsnagClient.notify(heapAnalysis.exception)
702*d9e8da70SAndroid Build Coastguard Worker      }
703*d9e8da70SAndroid Build Coastguard Worker    }
704*d9e8da70SAndroid Build Coastguard Worker  }
705*d9e8da70SAndroid Build Coastguard Worker
706*d9e8da70SAndroid Build Coastguard Worker  // Exception with fake unique stacktrace to send all reports to the same error entry.
707*d9e8da70SAndroid Build Coastguard Worker  class HeapAnalysisReport : Exception("Check the HEAP ANALYSIS tab") {
708*d9e8da70SAndroid Build Coastguard Worker    override fun fillInStackTrace(): Throwable {
709*d9e8da70SAndroid Build Coastguard Worker      stackTrace = arrayOf(
710*d9e8da70SAndroid Build Coastguard Worker        StackTraceElement(
711*d9e8da70SAndroid Build Coastguard Worker          "HeapAnalysisReport",
712*d9e8da70SAndroid Build Coastguard Worker          "analyzeHeap",
713*d9e8da70SAndroid Build Coastguard Worker          "HeapAnalysisReport.kt",
714*d9e8da70SAndroid Build Coastguard Worker          1
715*d9e8da70SAndroid Build Coastguard Worker        )
716*d9e8da70SAndroid Build Coastguard Worker      )
717*d9e8da70SAndroid Build Coastguard Worker      return this
718*d9e8da70SAndroid Build Coastguard Worker    }
719*d9e8da70SAndroid Build Coastguard Worker  }
720*d9e8da70SAndroid Build Coastguard Worker
721*d9e8da70SAndroid Build Coastguard Worker  companion object {
722*d9e8da70SAndroid Build Coastguard Worker    private const val BUGSNAG_API_KEY = YOUR_BUGSNAG_API_KEY
723*d9e8da70SAndroid Build Coastguard Worker    private const val DO_NOT_ENABLE_EXCEPTION_HANDLER = false
724*d9e8da70SAndroid Build Coastguard Worker  }
725*d9e8da70SAndroid Build Coastguard Worker}
726*d9e8da70SAndroid Build Coastguard Worker```
727*d9e8da70SAndroid Build Coastguard Worker
728*d9e8da70SAndroid Build Coastguard Worker### More leak fixes in Plumber
729*d9e8da70SAndroid Build Coastguard Worker
730*d9e8da70SAndroid Build Coastguard WorkerWe added 3 new automatic fixes for known AOSP leaks in `plumber-android` (details: [#1993](https://github.com/square/leakcanary/issues/1993)). As a reminder, `plumber-android` is automatically included when you add `leakcanary-android`, and you can add it manually for build types that don't include LeakCanary:
731*d9e8da70SAndroid Build Coastguard Worker
732*d9e8da70SAndroid Build Coastguard Worker```gradle
733*d9e8da70SAndroid Build Coastguard Workerdependencies {
734*d9e8da70SAndroid Build Coastguard Worker  // leakcanary-android adds plumber-android to debug builds
735*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
736*d9e8da70SAndroid Build Coastguard Worker
737*d9e8da70SAndroid Build Coastguard Worker  // This adds plumber-android to all build types
738*d9e8da70SAndroid Build Coastguard Worker  implementation 'com.squareup.leakcanary:plumber-android:2.6'
739*d9e8da70SAndroid Build Coastguard Worker}
740*d9e8da70SAndroid Build Coastguard Worker```
741*d9e8da70SAndroid Build Coastguard Worker
742*d9e8da70SAndroid Build Coastguard Worker### Bug fixes and improvements ����
743*d9e8da70SAndroid Build Coastguard Worker
744*d9e8da70SAndroid Build Coastguard Worker* [#1948](https://github.com/square/leakcanary/pull/1948) Leakcanary is now compiled against Kotlin 1.4 (while staying 1.3 compatible) to support [Functional (SAM) interfaces](https://kotlinlang.org/docs/reference/fun-interfaces.html).
745*d9e8da70SAndroid Build Coastguard Worker* [#1956](https://github.com/square/leakcanary/issues/1956) The retained object size is displayed as a human readable output (KB, MB, ...).
746*d9e8da70SAndroid Build Coastguard Worker* [#1976](https://github.com/square/leakcanary/issues/1976) Improved default object inspectors and leak finders for `View` and `Context`.
747*d9e8da70SAndroid Build Coastguard Worker* [#1972](https://github.com/square/leakcanary/issues/1972) Fields are printed with the parent class name that holds the field in leak traces.
748*d9e8da70SAndroid Build Coastguard Worker* [#1981](https://github.com/square/leakcanary/issues/1981) Fixed StrictMode policy violation (main thread read from disk).
749*d9e8da70SAndroid Build Coastguard Worker* [#1977](https://github.com/square/leakcanary/issues/1977) Report objects that are not strongly reachable.
750*d9e8da70SAndroid Build Coastguard Worker* [#2018](https://github.com/square/leakcanary/pull/2018) & [#2019](https://github.com/square/leakcanary/pull/2019) Fixed crashes in LeakCanary UI (discovered by Monkey tests).
751*d9e8da70SAndroid Build Coastguard Worker* [#2015](https://github.com/square/leakcanary/issues/2015) Fixed crash on Android < 16.
752*d9e8da70SAndroid Build Coastguard Worker* [#2023](https://github.com/square/leakcanary/issues/2023) Fixed crash in plugin projects.
753*d9e8da70SAndroid Build Coastguard Worker
754*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.6 Milestone](https://github.com/square/leakcanary/milestone/20) and the [full diff](https://github.com/square/leakcanary/compare/v2.5...v2.6).
755*d9e8da70SAndroid Build Coastguard Worker
756*d9e8da70SAndroid Build Coastguard Worker## Version 2.5 (2020-10-01)
757*d9e8da70SAndroid Build Coastguard Worker
758*d9e8da70SAndroid Build Coastguard WorkerPlease thank
759*d9e8da70SAndroid Build Coastguard Worker[@Amokrane](https://github.com/Amokrane),
760*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
761*d9e8da70SAndroid Build Coastguard Worker[@askont](https://github.com/askont),
762*d9e8da70SAndroid Build Coastguard Worker[@chao2zhang](https://github.com/chao2zhang),
763*d9e8da70SAndroid Build Coastguard Worker[@daniil-shevtsov](https://github.com/daniil-shevtsov),
764*d9e8da70SAndroid Build Coastguard Worker[@eygraber](https://github.com/eygraber),
765*d9e8da70SAndroid Build Coastguard Worker[@msfjarvis](https://github.com/msfjarvis),
766*d9e8da70SAndroid Build Coastguard Worker[@mzgreen](https://github.com/mzgreen),
767*d9e8da70SAndroid Build Coastguard Worker[@lchen8](https://github.com/lchen8),
768*d9e8da70SAndroid Build Coastguard Worker[@rpattabi](https://github.com/rpattabi),
769*d9e8da70SAndroid Build Coastguard Worker[@sahil2441](https://github.com/sahil2441),
770*d9e8da70SAndroid Build Coastguard Worker[@SylvainGirod](https://github.com/SylvainGirod),
771*d9e8da70SAndroid Build Coastguard Worker[@vhow](https://github.com/vhow)
772*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests �� �� ��.
773*d9e8da70SAndroid Build Coastguard Worker
774*d9e8da70SAndroid Build Coastguard Worker### Heap analysis is twice as fast ����
775*d9e8da70SAndroid Build Coastguard Worker
776*d9e8da70SAndroid Build Coastguard WorkerNo one asked, so we delivered! We rewrote several core components in Shark (LeakCanary's heap analyzer) to dramatically reduce IO reads and allocations while keeping memory constant. More details on Twitter: [thread by @ArtemChubaryan](https://twitter.com/ArtemChubaryan/status/1311078061895553030) and [thread by @Piwai](https://twitter.com/Piwai/status/1311085280753926144).
777*d9e8da70SAndroid Build Coastguard Worker
778*d9e8da70SAndroid Build Coastguard Worker### Compute retained size within the leak trace
779*d9e8da70SAndroid Build Coastguard Worker
780*d9e8da70SAndroid Build Coastguard WorkerPreviously, LeakCanary computed the retained size for the leaking object (the last object in the leak trace). However, the bad reference causing objects to leak is often higher up in the leak trace and everything that it holds onto is actually leaking. So LeakCanary now computes the retained size for [all the objects in the leaktrace that have a LEAKING or UNKNOWN status](https://github.com/square/leakcanary/issues/1880):
781*d9e8da70SAndroid Build Coastguard Worker
782*d9e8da70SAndroid Build Coastguard Worker```
783*d9e8da70SAndroid Build Coastguard Worker┬───
784*d9e8da70SAndroid Build Coastguard Worker│ GC Root: System class
785*d9e8da70SAndroid Build Coastguard Worker786*d9e8da70SAndroid Build Coastguard Worker├─ com.example.MySingleton class
787*d9e8da70SAndroid Build Coastguard Worker│    Leaking: NO (a class is never leaking)
788*d9e8da70SAndroid Build Coastguard Worker│    ↓ static MySingleton.leakedView
789*d9e8da70SAndroid Build Coastguard Worker│                         ~~~~~~~~~~
790*d9e8da70SAndroid Build Coastguard Worker├─ android.widget.TextView instance
791*d9e8da70SAndroid Build Coastguard Worker│    Leaking: YES (View.mContext references a destroyed activity)
792*d9e8da70SAndroid Build Coastguard Worker│    Retaining 46326 bytes in 942 objects
793*d9e8da70SAndroid Build Coastguard Worker│    ↓ TextView.mContext
794*d9e8da70SAndroid Build Coastguard Worker╰→ com.example.MainActivity instance
795*d9e8da70SAndroid Build Coastguard Worker​     Leaking: YES (Activity#mDestroyed is true)
796*d9e8da70SAndroid Build Coastguard Worker​     Retaining 1432 bytes in 36 objects
797*d9e8da70SAndroid Build Coastguard Worker```
798*d9e8da70SAndroid Build Coastguard Worker
799*d9e8da70SAndroid Build Coastguard Worker### Disable LeakCanary from the UI
800*d9e8da70SAndroid Build Coastguard Worker
801*d9e8da70SAndroid Build Coastguard WorkerNew toggle to disable [heap dumping](https://github.com/square/leakcanary/issues/1886), which can be useful for QA, or when doing a product demo. LeakCanary will still show a notification when an object is retained.
802*d9e8da70SAndroid Build Coastguard Worker
803*d9e8da70SAndroid Build Coastguard Worker![disable heap dumping](images/disable_dumping.png)
804*d9e8da70SAndroid Build Coastguard Worker
805*d9e8da70SAndroid Build Coastguard Worker### Deobfuscating hprof files
806*d9e8da70SAndroid Build Coastguard Worker
807*d9e8da70SAndroid Build Coastguard WorkerThe [Shark CLI](shark.md#shark-cli) can now [deobfuscate heap dumps](https://github.com/square/leakcanary/issues/1698):
808*d9e8da70SAndroid Build Coastguard Worker
809*d9e8da70SAndroid Build Coastguard Worker```
810*d9e8da70SAndroid Build Coastguard Workerbrew install leakcanary-shark
811*d9e8da70SAndroid Build Coastguard Worker
812*d9e8da70SAndroid Build Coastguard Workershark-cli --hprof heapdump.hprof -m mapping.txt deobfuscate-hprof
813*d9e8da70SAndroid Build Coastguard Worker```
814*d9e8da70SAndroid Build Coastguard Worker
815*d9e8da70SAndroid Build Coastguard Worker### Bug fixes and improvements ����
816*d9e8da70SAndroid Build Coastguard Worker
817*d9e8da70SAndroid Build Coastguard Worker* Heap analysis text results now [wrap to a max width](https://github.com/square/leakcanary/issues/1811) when sharing them from the LeakCanary activity or printing to logcat. This will make it harder to miss details that are lost at the end of long lines of text.
818*d9e8da70SAndroid Build Coastguard Worker* The `leak_canary_watcher_auto_install`, `leak_canary_allow_in_non_debuggable_build` and `leak_canary_plumber_auto_install` resource booleans were [meant to be public](https://github.com/square/leakcanary/issues/1863).
819*d9e8da70SAndroid Build Coastguard Worker* We sprinkled a few `@JvmStatic` to [help Java consummers](https://github.com/square/leakcanary/issues/1870).
820*d9e8da70SAndroid Build Coastguard Worker* Fixed [crash when no browser installed](https://github.com/square/leakcanary/pull/1893).
821*d9e8da70SAndroid Build Coastguard Worker* Use distinct [group for LeakCanary notifications](https://github.com/square/leakcanary/issues/1845).
822*d9e8da70SAndroid Build Coastguard Worker* The heap analysis result now includes the [heap dump duration](https://github.com/square/leakcanary/pull/1931) because it looks like Android 11 heap dumps are [sometimes super slow](https://issuetracker.google.com/issues/168634429). We also added more [perf related metrics](https://github.com/square/leakcanary/issues/1929).
823*d9e8da70SAndroid Build Coastguard Worker* [Disable logging](https://github.com/square/leakcanary/issues/1910) when AppWatcher runs in release builds.
824*d9e8da70SAndroid Build Coastguard Worker* Highlight library leak patterns [directly within the leak traces](https://github.com/square/leakcanary/issues/1916).
825*d9e8da70SAndroid Build Coastguard Worker* Improved inspections for [Context, View](https://github.com/square/leakcanary/issues/1912) and [ContextImpl](https://github.com/square/leakcanary/pull/1884).
826*d9e8da70SAndroid Build Coastguard Worker
827*d9e8da70SAndroid Build Coastguard Worker
828*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.5 Milestone](https://github.com/square/leakcanary/milestone/19) and the [full diff](https://github.com/square/leakcanary/compare/v2.4...v2.5).
829*d9e8da70SAndroid Build Coastguard Worker
830*d9e8da70SAndroid Build Coastguard Worker
831*d9e8da70SAndroid Build Coastguard Worker## Version 2.4 (2020-06-10)
832*d9e8da70SAndroid Build Coastguard Worker
833*d9e8da70SAndroid Build Coastguard WorkerPlease thank
834*d9e8da70SAndroid Build Coastguard Worker[@0x109](https://github.com/0x109),
835*d9e8da70SAndroid Build Coastguard Worker[@andersu](https://github.com/andersu),
836*d9e8da70SAndroid Build Coastguard Worker[@antoniomerlin](https://github.com/antoniomerlin),
837*d9e8da70SAndroid Build Coastguard Worker[@bishiboosh](https://github.com/bishiboosh),
838*d9e8da70SAndroid Build Coastguard Worker[@ckesc](https://github.com/ckesc),
839*d9e8da70SAndroid Build Coastguard Worker[@jrodbx](https://github.com/jrodbx),
840*d9e8da70SAndroid Build Coastguard Worker[@LouisCAD](https://github.com/LouisCAD),
841*d9e8da70SAndroid Build Coastguard Worker[@marcardar](https://github.com/marcardar),
842*d9e8da70SAndroid Build Coastguard Worker[@OlivierGenez](https://github.com/OlivierGenez),
843*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
844*d9e8da70SAndroid Build Coastguard Worker[@runningcode](https://github.com/runningcode),
845*d9e8da70SAndroid Build Coastguard Worker[@seljad](https://github.com/seljad),
846*d9e8da70SAndroid Build Coastguard Worker[@worldsnas](https://github.com/worldsnas)
847*d9e8da70SAndroid Build Coastguard Workerfor their contributions, bug reports and feature requests.
848*d9e8da70SAndroid Build Coastguard Worker
849*d9e8da70SAndroid Build Coastguard Worker### `plumber-android` is a new artifact that fixes known Android leaks ����
850*d9e8da70SAndroid Build Coastguard Worker
851*d9e8da70SAndroid Build Coastguard WorkerLeakCanary reports all leaks, including leaks caused by a known bug in 3rd party code that you do not have control over (reported as [Library leaks](fundamentals-how-leakcanary-works.md#4-categorizing-leaks)). That can be annoying! LeakCanary now ships with a new dependency, `plumber-android`, which performs hacks at runtime to fix some of these known leaks. This releases has fixes for **11 known leaks**, but this is just the beginning. Contributions welcome! ��
852*d9e8da70SAndroid Build Coastguard Worker
853*d9e8da70SAndroid Build Coastguard WorkerNote that since the `leakcanary-android` dependency is usually added as a `debugImplementation` dependency, the `plumber-android` is transitively added only in debug builds, so it will not fix leaks in your release builds. You can add the dependency directly as `implementation` to get these fixes in release builds as well:
854*d9e8da70SAndroid Build Coastguard Worker
855*d9e8da70SAndroid Build Coastguard Worker```groovy
856*d9e8da70SAndroid Build Coastguard Workerdependencies {
857*d9e8da70SAndroid Build Coastguard Worker  implementation 'com.squareup.leakcanary:plumber-android:2.4'
858*d9e8da70SAndroid Build Coastguard Worker}
859*d9e8da70SAndroid Build Coastguard Worker```
860*d9e8da70SAndroid Build Coastguard Worker
861*d9e8da70SAndroid Build Coastguard Worker!!! warning
862*d9e8da70SAndroid Build Coastguard Worker    While several of these fixes already ship in release builds of Square apps, this is the first official release of `plumber-android`, so you should consider it **experimental**.
863*d9e8da70SAndroid Build Coastguard Worker
864*d9e8da70SAndroid Build Coastguard Worker### Analyzing leaks from the CLI is easier than ever ��
865*d9e8da70SAndroid Build Coastguard Worker
866*d9e8da70SAndroid Build Coastguard WorkerThe [Shark CLI](shark.md#shark-cli) can now be installed via [Homebrew](https://brew.sh/)
867*d9e8da70SAndroid Build Coastguard Worker
868*d9e8da70SAndroid Build Coastguard Worker```
869*d9e8da70SAndroid Build Coastguard Workerbrew install leakcanary-shark
870*d9e8da70SAndroid Build Coastguard Worker```
871*d9e8da70SAndroid Build Coastguard Worker
872*d9e8da70SAndroid Build Coastguard WorkerYou can then look for leaks in apps on any connected device, for example:
873*d9e8da70SAndroid Build Coastguard Worker
874*d9e8da70SAndroid Build Coastguard Worker```
875*d9e8da70SAndroid Build Coastguard Worker$ shark-cli --device emulator-5554 --process com.example.app.debug analyze
876*d9e8da70SAndroid Build Coastguard Worker```
877*d9e8da70SAndroid Build Coastguard Worker
878*d9e8da70SAndroid Build Coastguard Worker### Support for Android Test Orchestrator ��
879*d9e8da70SAndroid Build Coastguard Worker
880*d9e8da70SAndroid Build Coastguard WorkerIf you set up LeakCanary to report test failures when detecting leaks in instrumentation tests, it [now works](https://github.com/square/leakcanary/issues/1046) with Android Test Orchestrator as well. No change required, LeakCanary will automatically detect thatAndroid Test Orchestrator is running and hook into it.
881*d9e8da70SAndroid Build Coastguard Worker
882*d9e8da70SAndroid Build Coastguard Worker### No more `master` branch
883*d9e8da70SAndroid Build Coastguard Worker
884*d9e8da70SAndroid Build Coastguard WorkerThe branch name `master` comes from the *master / slave* terminology. We renamed the default branch to `main`, a small step towards making the LeakCanary community a safer space. Here's a good [thread on this topic](https://twitter.com/mislav/status/1270388510684598272).
885*d9e8da70SAndroid Build Coastguard Worker
886*d9e8da70SAndroid Build Coastguard Worker### Bug fixes and improvements ����
887*d9e8da70SAndroid Build Coastguard Worker
888*d9e8da70SAndroid Build Coastguard Worker* URLs in *Library Leak* descriptions are [now clickable](https://github.com/square/leakcanary/issues/1844)
889*d9e8da70SAndroid Build Coastguard Worker* Fixed [ordering issues](https://github.com/square/leakcanary/issues/1832) causing improper config with manual setup. A related change is that `AppWatcher.Config.enabled` is now deprecated.
890*d9e8da70SAndroid Build Coastguard Worker* Fixed possible [OutOfMemoryError failure](https://github.com/square/leakcanary/issues/1798) when computing retained size: we were loading to memory large arrays from the heap dump just to get their size.
891*d9e8da70SAndroid Build Coastguard Worker
892*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.4 Milestone](https://github.com/square/leakcanary/milestone/18) and the [full diff](https://github.com/square/leakcanary/compare/v2.3...v2.4).
893*d9e8da70SAndroid Build Coastguard Worker
894*d9e8da70SAndroid Build Coastguard Worker## Version 2.3 (2020-04-08)
895*d9e8da70SAndroid Build Coastguard Worker
896*d9e8da70SAndroid Build Coastguard WorkerThis is a minor release on the feature front, but a large release on the documentation front!
897*d9e8da70SAndroid Build Coastguard Worker
898*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
899*d9e8da70SAndroid Build Coastguard Worker[@adamfit](https://github.com/adamfit),
900*d9e8da70SAndroid Build Coastguard Worker[@Amokrane](https://github.com/Amokrane),
901*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
902*d9e8da70SAndroid Build Coastguard Worker[@artnc](https://github.com/artnc),
903*d9e8da70SAndroid Build Coastguard Worker[@burakeregar](https://github.com/burakeregar),
904*d9e8da70SAndroid Build Coastguard Worker[@ClaasJG](https://github.com/ClaasJG),
905*d9e8da70SAndroid Build Coastguard Worker[@clementcontet](https://github.com/clementcontet),
906*d9e8da70SAndroid Build Coastguard Worker[@ckesc](https://github.com/ckesc),
907*d9e8da70SAndroid Build Coastguard Worker[@cketti](https://github.com/cketti),
908*d9e8da70SAndroid Build Coastguard Worker[@fbenbassat](https://github.com/fbenbassat),
909*d9e8da70SAndroid Build Coastguard Worker[@Guneetgstar](https://github.com/Guneetgstar),
910*d9e8da70SAndroid Build Coastguard Worker[@Igorxp5](https://github.com/Igorxp5),
911*d9e8da70SAndroid Build Coastguard Worker[@JLLeitschuh](https://github.com/JLLeitschuh),
912*d9e8da70SAndroid Build Coastguard Worker[@KidAndroid](https://github.com/KidAndroid),
913*d9e8da70SAndroid Build Coastguard Worker[@ligi](https://github.com/ligi),
914*d9e8da70SAndroid Build Coastguard Worker[@mzgreen](https://github.com/mzgreen),
915*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
916*d9e8da70SAndroid Build Coastguard Worker[@sprintuu](https://github.com/sprintuu),
917*d9e8da70SAndroid Build Coastguard Worker[@tevjef](https://github.com/tevjef),
918*d9e8da70SAndroid Build Coastguard Worker[@thrlr123](https://github.com/thrlr123)
919*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
920*d9e8da70SAndroid Build Coastguard Worker
921*d9e8da70SAndroid Build Coastguard WorkerWe [asked for help](https://twitter.com/Piwai/status/1253454280758980609) and immediately started seeing more contributions. Thanks all! Check out the [How to help](how_to_help.md) page.
922*d9e8da70SAndroid Build Coastguard Worker
923*d9e8da70SAndroid Build Coastguard Worker### LeakCanary will now crash in release builds
924*d9e8da70SAndroid Build Coastguard Worker
925*d9e8da70SAndroid Build Coastguard WorkerDespite the documentation insisting on using `debugImplementation`, we've seen apps [ship LeakCanary](https://twitter.com/Piwai/status/1245524534712602624) in **release builds**. Mistakes happen, so we've made that mistake [harder to miss](https://github.com/square/leakcanary/issues/1804) by making LeakCanary **crash when included in release builds**.
926*d9e8da70SAndroid Build Coastguard Worker
927*d9e8da70SAndroid Build Coastguard WorkerLearn More: [LeakCanary in release builds](recipes.md#leakcanary-in-release-builds).
928*d9e8da70SAndroid Build Coastguard Worker
929*d9e8da70SAndroid Build Coastguard Worker### Doc site ����
930*d9e8da70SAndroid Build Coastguard Worker
931*d9e8da70SAndroid Build Coastguard WorkerThe doc site content has changed quite a bit! We applied advice from [Google's tech writing guide](https://developers.google.com/tech-writing/). If you've been confused by *Library Leaks* before, check out see the new [Categorizing leaks](fundamentals-how-leakcanary-works.md#4-categorizing-leaks) section. Take a look around, let us know what you think.
932*d9e8da70SAndroid Build Coastguard Worker
933*d9e8da70SAndroid Build Coastguard Worker### Bug fixes and improvements ��
934*d9e8da70SAndroid Build Coastguard Worker
935*d9e8da70SAndroid Build Coastguard Worker* The new [deobfuscation Gradle plugin](recipes.md#using-leakcanary-with-obfuscated-apps) wasn't working [with Gradle 3.6](https://github.com/square/leakcanary/issues/1761), this is now fixed. Also removed the requirement for the plugin to be [applied after AGP](https://github.com/square/leakcanary/pull/1816).
936*d9e8da70SAndroid Build Coastguard Worker* Fixed 2 crashes ([#1768](https://github.com/square/leakcanary/issues/1768) & [#1769](https://github.com/square/leakcanary/issues/1769)) in the LeakCanary UI found by a sneaky monkey runner ��.
937*d9e8da70SAndroid Build Coastguard Worker* The LeakCanary UI updates [immediately](https://github.com/square/leakcanary/issues/1742) when a heap analysis is added or deleted.
938*d9e8da70SAndroid Build Coastguard Worker* Fixed a crash when [updating from LeakCanary 2.0](https://github.com/square/leakcanary/pull/1800).
939*d9e8da70SAndroid Build Coastguard Worker* The *About* section of the LeakCanary now surfaces whether heap dumping is [currently enabled](https://github.com/square/leakcanary/issues/1803).
940*d9e8da70SAndroid Build Coastguard Worker* Fixed process [not exiting](https://github.com/square/leakcanary/issues/1711) in SharkCLI on Windows.
941*d9e8da70SAndroid Build Coastguard Worker* Improved [error message](https://github.com/square/leakcanary/pull/1823) when obfuscation mappings appear to be missing.
942*d9e8da70SAndroid Build Coastguard Worker
943*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.3 Milestone](https://github.com/square/leakcanary/milestone/17) and the [full diff](https://github.com/square/leakcanary/compare/v2.2...v2.3).
944*d9e8da70SAndroid Build Coastguard Worker
945*d9e8da70SAndroid Build Coastguard Worker## Version 2.2 (2020-02-05)
946*d9e8da70SAndroid Build Coastguard Worker
947*d9e8da70SAndroid Build Coastguard WorkerWe've got some good stuff for the first release of the decade!
948*d9e8da70SAndroid Build Coastguard Worker
949*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
950*d9e8da70SAndroid Build Coastguard Worker[@AndroidInternal](https://github.com/AndroidInternal),
951*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
952*d9e8da70SAndroid Build Coastguard Worker[@lic2050](https://github.com/lic2050),
953*d9e8da70SAndroid Build Coastguard Worker[@mzgreen](https://github.com/mzgreen),
954*d9e8da70SAndroid Build Coastguard Worker[@orenktaboola](https://github.com/orenktaboola),
955*d9e8da70SAndroid Build Coastguard Worker[@personshelldon](https://github.com/personshelldon),
956*d9e8da70SAndroid Build Coastguard Worker[@Plastix](https://github.com/Plastix),
957*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau)
958*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
959*d9e8da70SAndroid Build Coastguard Worker
960*d9e8da70SAndroid Build Coastguard Worker### ViewModel leak detection
961*d9e8da70SAndroid Build Coastguard Worker
962*d9e8da70SAndroid Build Coastguard Worker[Android ViewModels](https://developer.android.com/topic/libraries/architecture/viewmodel) are really cool! Their lifecycle is much nicer than fragments or activities, but sometimes mistakes happen. LeakCanary will now automatically detect ViewModel leaks and report any ViewModel instance retained after its `onCleared()` method was called.
963*d9e8da70SAndroid Build Coastguard Worker
964*d9e8da70SAndroid Build Coastguard Worker### Android TV
965*d9e8da70SAndroid Build Coastguard Worker
966*d9e8da70SAndroid Build Coastguard Worker![tv ui](images/android-tv-leaks.png)
967*d9e8da70SAndroid Build Coastguard Worker
968*d9e8da70SAndroid Build Coastguard WorkerLeakCanary is finally coming to big screens near you! Best part - no additional setup is required, just enable it like you would for a [mobile device](getting_started.md). Now whenever there's a leak - you will see a helpful Toast appear with all the details. Make sure to check out our new [Android TV](recipes.md#android-tv) section and chill!
969*d9e8da70SAndroid Build Coastguard Worker
970*d9e8da70SAndroid Build Coastguard Worker### Java-friendly Config builders
971*d9e8da70SAndroid Build Coastguard Worker
972*d9e8da70SAndroid Build Coastguard Worker[It was brought to our attention](https://github.com/square/leakcanary/issues/1714) that configuring `LeakCanary` and `AppWatcher` was a miserable experience from Java code. Well, not anymore!
973*d9e8da70SAndroid Build Coastguard Worker
974*d9e8da70SAndroid Build Coastguard WorkerNow you can use `LeakCanary.Config.Builder` and `AppWatcher.Config.Builder` to have idiomatic Java when updating the configurations. For example:
975*d9e8da70SAndroid Build Coastguard Worker
976*d9e8da70SAndroid Build Coastguard Worker```
977*d9e8da70SAndroid Build Coastguard WorkerLeakCanary.Config config = LeakCanary.getConfig().newBuilder()
978*d9e8da70SAndroid Build Coastguard Worker  .retainedVisibleThreshold(3)
979*d9e8da70SAndroid Build Coastguard Worker  .computeRetainedHeapSize(false)
980*d9e8da70SAndroid Build Coastguard Worker  .build();
981*d9e8da70SAndroid Build Coastguard WorkerLeakCanary.setConfig(config);
982*d9e8da70SAndroid Build Coastguard Worker```
983*d9e8da70SAndroid Build Coastguard Worker
984*d9e8da70SAndroid Build Coastguard WorkerIf you notice any other problems when using LeakCanary from Java, please [file an issue](https://github.com/square/leakcanary/issues/new?assignees=&labels=type%3A+enhancement&template=3-feature.md&title=)! We take Java-interop seriously and will be happy to improve LeakCanary's API!
985*d9e8da70SAndroid Build Coastguard Worker
986*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.2 Milestone](https://github.com/square/leakcanary/milestone/16) and the [full diff](https://github.com/square/leakcanary/compare/v2.1...v2.2).
987*d9e8da70SAndroid Build Coastguard Worker
988*d9e8da70SAndroid Build Coastguard Worker## Version 2.1 (2019-12-31)
989*d9e8da70SAndroid Build Coastguard Worker
990*d9e8da70SAndroid Build Coastguard WorkerA special New Year's Eve release ��, the next release will be in another decade ��!
991*d9e8da70SAndroid Build Coastguard Worker
992*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
993*d9e8da70SAndroid Build Coastguard Worker[@adamfit](https://github.com/adamfit),
994*d9e8da70SAndroid Build Coastguard Worker[@alexander-smityuk](https://github.com/alexander-smityuk),
995*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
996*d9e8da70SAndroid Build Coastguard Worker[@BraisGabin](https://github.com/BraisGabin),
997*d9e8da70SAndroid Build Coastguard Worker[@devism](https://github.com/devism),
998*d9e8da70SAndroid Build Coastguard Worker[@ditclear](https://github.com/ditclear),
999*d9e8da70SAndroid Build Coastguard Worker[@jrodbx](https://github.com/jrodbx),
1000*d9e8da70SAndroid Build Coastguard Worker[@jstefanowski](https://github.com/jstefanowski),
1001*d9e8da70SAndroid Build Coastguard Worker[@Maragues](https://github.com/Maragues),
1002*d9e8da70SAndroid Build Coastguard Worker[@mzgreen](https://github.com/mzgreen),
1003*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau)
1004*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1005*d9e8da70SAndroid Build Coastguard Worker
1006*d9e8da70SAndroid Build Coastguard Worker### A Gradle plugin for obfuscated apps
1007*d9e8da70SAndroid Build Coastguard Worker
1008*d9e8da70SAndroid Build Coastguard WorkerIt's fairly common for teams to have a QA build that is tested before making the release build. Usually that build will be obfuscated (via Proguard or R8), but also add LeakCanary to detect leaks during QA. This leads to obfuscated leak traces, which are hard to understand ��. Check out our new [Gradle deobfuscation plugin](recipes.md#using-leakcanary-with-obfuscated-apps) and rejoice!
1009*d9e8da70SAndroid Build Coastguard Worker
1010*d9e8da70SAndroid Build Coastguard Worker### UI <strike>twix</strike> tweaks
1011*d9e8da70SAndroid Build Coastguard Worker
1012*d9e8da70SAndroid Build Coastguard WorkerIn 2.0 we changed the LeakCanary UI and UX, and built a foundation on which 2.1 extends.
1013*d9e8da70SAndroid Build Coastguard Worker
1014*d9e8da70SAndroid Build Coastguard Worker![ui](images/screenshot-2.0.png)
1015*d9e8da70SAndroid Build Coastguard Worker
1016*d9e8da70SAndroid Build Coastguard Worker* Since 2.0, Leaks are grouped by their distinct signature. In 2.1 there's a `New` tag that will show until you open up a leak. There's also a `Library Leak` tag for leaks that are known to be caused by a bug in the Android Framework or Google libraries, and the library leak description now shows up in the UI.
1017*d9e8da70SAndroid Build Coastguard Worker* The type of the Java objects (class, instance, array) is now displayed in the LeakTrace, e.g. see `FontsContract class` and `ExampleApplication instance` above.
1018*d9e8da70SAndroid Build Coastguard Worker* The type of the GC root now shows up at the root of the leak trace. Makes sense!
1019*d9e8da70SAndroid Build Coastguard Worker* The leak result notification has an importance now set to MAX so that it'll show up right in your face. If you turn it off, the canary will haunt you in your dreams ����. To save your sanity and your device battery, automatic heap dumps now won't happen more often than once per minute.
1020*d9e8da70SAndroid Build Coastguard Worker* The resource id name for `View` instances is now displayed in the leak trace. You shouldn't look at the [implementation](https://github.com/square/leakcanary/pull/1663).
1021*d9e8da70SAndroid Build Coastguard Worker
1022*d9e8da70SAndroid Build Coastguard Worker```
1023*d9e8da70SAndroid Build Coastguard Worker├─ android.widget.TextView instance
1024*d9e8da70SAndroid Build Coastguard WorkerView.mID = R.id.helper_text
1025*d9e8da70SAndroid Build Coastguard Worker```
1026*d9e8da70SAndroid Build Coastguard Worker
1027*d9e8da70SAndroid Build Coastguard Worker### Documentation goodies
1028*d9e8da70SAndroid Build Coastguard Worker
1029*d9e8da70SAndroid Build Coastguard Worker* The [Fundamentals](fundamentals.md) page was entirely rewritten, split into 3 pages and moved to its own tab. Please read it and provide feedback!
1030*d9e8da70SAndroid Build Coastguard Worker* At Square, we have been uploading leaks to Bugsnag for 3 years now, so that no leak ever gets missed. Follow [this recipe](uploading.md)!
1031*d9e8da70SAndroid Build Coastguard Worker* Did you know you can [run LeakCanary in a JVM](recipes.md#detecting-leaks-in-jvm-applications)?
1032*d9e8da70SAndroid Build Coastguard Worker
1033*d9e8da70SAndroid Build Coastguard Worker### API <strike>breaking</strike> bettering changes
1034*d9e8da70SAndroid Build Coastguard Worker
1035*d9e8da70SAndroid Build Coastguard Worker* The APIs of the `Leak` and `LeakTrace` classes have significantly changed, e.g. all `LeakTrace` instances with an identical signature are grouped under the same Leak object. Despite these breaking changes, this release version is a minor update. Oh noes, what about semantic versioning ��? Ask Don Quixote.
1036*d9e8da70SAndroid Build Coastguard Worker* You can now customize the way LeakCanary finds the leaking objects in the heap dump. For example, here's the configuration SharkCli uses to find leaks in heap dumps of apps that don't even have the LeakCanary dependency:
1037*d9e8da70SAndroid Build Coastguard Worker
1038*d9e8da70SAndroid Build Coastguard Worker```kotlin
1039*d9e8da70SAndroid Build Coastguard WorkerLeakCanary.config = LeakCanary.config.copy(
1040*d9e8da70SAndroid Build Coastguard Worker    leakingObjectFinder = FilteringLeakingObjectFinder(
1041*d9e8da70SAndroid Build Coastguard Worker        AndroidObjectInspectors.appLeakingObjectFilters
1042*d9e8da70SAndroid Build Coastguard Worker    )
1043*d9e8da70SAndroid Build Coastguard Worker)
1044*d9e8da70SAndroid Build Coastguard Worker```
1045*d9e8da70SAndroid Build Coastguard Worker
1046*d9e8da70SAndroid Build Coastguard Worker* LeakCanary automatically disables itself in tests by detecting that the `org.junit.Test` is in the classpath. Unfortunately, some apps ship Junit in their app debug classpath (e.g. when using OkHttp MockWebServer). You can now customize which class is used to detect tests:
1047*d9e8da70SAndroid Build Coastguard Worker
1048*d9e8da70SAndroid Build Coastguard Worker```xml
1049*d9e8da70SAndroid Build Coastguard Worker<resources>
1050*d9e8da70SAndroid Build Coastguard Worker  <string name="leak_canary_test_class_name">assertk.Assert</string>
1051*d9e8da70SAndroid Build Coastguard Worker</resources>
1052*d9e8da70SAndroid Build Coastguard Worker```
1053*d9e8da70SAndroid Build Coastguard Worker
1054*d9e8da70SAndroid Build Coastguard Worker### Interactive CLI
1055*d9e8da70SAndroid Build Coastguard Worker
1056*d9e8da70SAndroid Build Coastguard Worker[Shark CLI](https://github.com/square/leakcanary/releases/download/v2.1/shark-cli-2.1.zip) was rewritten on top of [Clikt](https://github.com/ajalt/clikt):
1057*d9e8da70SAndroid Build Coastguard Worker
1058*d9e8da70SAndroid Build Coastguard Worker```bash
1059*d9e8da70SAndroid Build Coastguard Worker$ shark-cli
1060*d9e8da70SAndroid Build Coastguard WorkerUsage: shark-cli [OPTIONS] COMMAND [ARGS]...
1061*d9e8da70SAndroid Build Coastguard Worker
1062*d9e8da70SAndroid Build Coastguard Worker                 ^`.                 .=""=.
1063*d9e8da70SAndroid Build Coastguard Worker ^_              \  \               / _  _ \
1064*d9e8da70SAndroid Build Coastguard Worker \ \             {   \             |  d  b  |
1065*d9e8da70SAndroid Build Coastguard Worker {  \           /     `~~~--__     \   /\   /
1066*d9e8da70SAndroid Build Coastguard Worker {   \___----~~'              `~~-_/'-=\/=-'\,
1067*d9e8da70SAndroid Build Coastguard Worker  \                         /// a  `~.      \ \
1068*d9e8da70SAndroid Build Coastguard Worker  / /~~~~-, ,__.    ,      ///  __,,,,)      \ |
1069*d9e8da70SAndroid Build Coastguard Worker  \/      \/    `~~~;   ,---~~-_`/ \        / \/
1070*d9e8da70SAndroid Build Coastguard Worker                   /   /            '.    .'
1071*d9e8da70SAndroid Build Coastguard Worker                  '._.'             _|`~~`|_
1072*d9e8da70SAndroid Build Coastguard Worker                                    /|\  /|\
1073*d9e8da70SAndroid Build Coastguard Worker
1074*d9e8da70SAndroid Build Coastguard WorkerOptions:
1075*d9e8da70SAndroid Build Coastguard Worker  -p, --process NAME              Full or partial name of a process, e.g.
1076*d9e8da70SAndroid Build Coastguard Worker                                  "example" would match "com.example.app"
1077*d9e8da70SAndroid Build Coastguard Worker  -d, --device ID                 device/emulator id
1078*d9e8da70SAndroid Build Coastguard Worker  -m, --obfuscation-mapping PATH  path to obfuscation mapping file
1079*d9e8da70SAndroid Build Coastguard Worker  --verbose / --no-verbose        provide additional details as to what
1080*d9e8da70SAndroid Build Coastguard Worker                                  shark-cli is doing
1081*d9e8da70SAndroid Build Coastguard Worker  -h, --hprof FILE                path to a .hprof file
1082*d9e8da70SAndroid Build Coastguard Worker  --help                          Show this message and exit
1083*d9e8da70SAndroid Build Coastguard Worker
1084*d9e8da70SAndroid Build Coastguard WorkerCommands:
1085*d9e8da70SAndroid Build Coastguard Worker  interactive   Explore a heap dump.
1086*d9e8da70SAndroid Build Coastguard Worker  analyze       Analyze a heap dump.
1087*d9e8da70SAndroid Build Coastguard Worker  dump-process  Dump the heap and pull the hprof file.
1088*d9e8da70SAndroid Build Coastguard Worker  strip-hprof   Replace all primitive arrays from the provided heap dump with
1089*d9e8da70SAndroid Build Coastguard Worker                arrays of zeroes and generate a new "-stripped.hprof" file.
1090*d9e8da70SAndroid Build Coastguard Worker```
1091*d9e8da70SAndroid Build Coastguard Worker
1092*d9e8da70SAndroid Build Coastguard WorkerThere's a new `interactive` command which enables exploring the heap dump from the command line:
1093*d9e8da70SAndroid Build Coastguard Worker
1094*d9e8da70SAndroid Build Coastguard Worker```bash
1095*d9e8da70SAndroid Build Coastguard Worker$ shark-cli -h heapdump.hprof interactive
1096*d9e8da70SAndroid Build Coastguard WorkerEnter command [help]:
1097*d9e8da70SAndroid Build Coastguard Workerhelp
1098*d9e8da70SAndroid Build Coastguard Worker
1099*d9e8da70SAndroid Build Coastguard WorkerAvailable commands:
1100*d9e8da70SAndroid Build Coastguard Worker  analyze                   Analyze the heap dump.
1101*d9e8da70SAndroid Build Coastguard Worker  class NAME@ID             Show class with a matching NAME and Object ID.
1102*d9e8da70SAndroid Build Coastguard Worker  instance CLASS_NAME@ID    Show instance with a matching CLASS_NAME and Object
1103*d9e8da70SAndroid Build Coastguard WorkerID.
1104*d9e8da70SAndroid Build Coastguard Worker  array CLASS_NAME@ID       Show array instance with a matching CLASS_NAME and
1105*d9e8da70SAndroid Build Coastguard WorkerObject ID.
1106*d9e8da70SAndroid Build Coastguard Worker  ->instance CLASS_NAME@ID  Show path from GC Roots to instance.
1107*d9e8da70SAndroid Build Coastguard Worker  ~>instance CLASS_NAME@ID  Show path from GC Roots to instance, highlighting
1108*d9e8da70SAndroid Build Coastguard Workersuspect references.
1109*d9e8da70SAndroid Build Coastguard Worker  help                      Show this message.
1110*d9e8da70SAndroid Build Coastguard Worker  exit                      Exit this interactive prompt.
1111*d9e8da70SAndroid Build Coastguard Worker```
1112*d9e8da70SAndroid Build Coastguard Worker
1113*d9e8da70SAndroid Build Coastguard WorkerWe're currently exploring the idea of adding [support for SQL queries](https://twitter.com/Piwai/status/1211795647273160704), feedback welcome!
1114*d9e8da70SAndroid Build Coastguard Worker
1115*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.1 Milestone](https://github.com/square/leakcanary/milestone/15) and the [full diff](https://github.com/square/leakcanary/compare/v2.0...v2.1).
1116*d9e8da70SAndroid Build Coastguard Worker
1117*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 (2019-11-27)
1118*d9e8da70SAndroid Build Coastguard Worker
1119*d9e8da70SAndroid Build Coastguard WorkerIn the past 7 months, LeakCanary went through 3 alphas and 5 betas, encompassing 23 contributors over 493 commits, 35826 insertions and 10156 deletions.
1120*d9e8da70SAndroid Build Coastguard Worker
1121*d9e8da70SAndroid Build Coastguard Worker### Should I upgrade?
1122*d9e8da70SAndroid Build Coastguard Worker
1123*d9e8da70SAndroid Build Coastguard Worker**YES!** LeakCanary 2 is so much better, it might make you excited when you see a new memory leak. Follow the [upgrade guide](upgrading-to-leakcanary-2.0.md), you won't regret it!
1124*d9e8da70SAndroid Build Coastguard Worker
1125*d9e8da70SAndroid Build Coastguard Worker### So, what's changed since 1.6.3?
1126*d9e8da70SAndroid Build Coastguard Worker
1127*d9e8da70SAndroid Build Coastguard Worker**Everything.** The LeakCanary codebase went from **~6000** lines of Java to **~16000** lines of Kotlin, excluding comments & blanks.
1128*d9e8da70SAndroid Build Coastguard Worker
1129*d9e8da70SAndroid Build Coastguard Worker!!! question "Isn't Kotlin supposed to drastically reduce the amount of boilerplate code?"
1130*d9e8da70SAndroid Build Coastguard Worker    Absolutely! And it did. But then, we wrote more code.
1131*d9e8da70SAndroid Build Coastguard Worker    LeakCanary used to depend on [HAHA](https://github.com/square/haha), a repackaging of [perflib](https://android.googlesource.com/platform/tools/base/+/2f03004c181baf9d291a9bf992e1b444e83cd82d/perflib/), the heap dump parser used by Android Studio. Unfortunately perflib was slow and used too much memory, so LeakCanary now includes its own heap dump parser: [Shark](shark.md). The extra code comes from Shark, but also from having a lot more automated tests, and an improved UI layer.
1132*d9e8da70SAndroid Build Coastguard Worker
1133*d9e8da70SAndroid Build Coastguard WorkerOne major difference: when the app is in foreground, LeakCanary 2 will not trigger on every retained instance. Instead it will wait until the app goes in background or to reach a threashold of 5 retained instances in foreground. The analysis will then find all the leaks at once, and group identical leaks in the results UI. Please read the [Fundamentals](fundamentals.md) section to learn more!
1134*d9e8da70SAndroid Build Coastguard Worker
1135*d9e8da70SAndroid Build Coastguard Worker### Random facts
1136*d9e8da70SAndroid Build Coastguard Worker
1137*d9e8da70SAndroid Build Coastguard Worker* You can customize the Leaks launcher icon and label: [learn more here](recipes.md#icon-and-label).
1138*d9e8da70SAndroid Build Coastguard Worker* If you ` press on your main activity launcher icon, you should see a LeakCanary dynamic shortcut. You can then long press that to drop it on your home screen, and the launcher shows that it's the leaks launcher for your app.
1139*d9e8da70SAndroid Build Coastguard Worker* Out of the box, LeakCanary tracks all fragments flavors: AOSP, Support Library and Android X.
1140*d9e8da70SAndroid Build Coastguard Worker* From within the leak screen, you can share a leak to stack overflow. You can also share a heap dump, or import and analyze a heap dump from another device.
1141*d9e8da70SAndroid Build Coastguard Worker* You can run LeakCanary from your computer command line, on any debuggable app even if that app doesn't have LeakCanary: [learn more here](shark.md##shark-cli).
1142*d9e8da70SAndroid Build Coastguard Worker* The new documentation is fully searchable and includes the API documentation. Try the search bar ⤴.
1143*d9e8da70SAndroid Build Coastguard Worker* A large 160Mb heap dump uses 2Gb memory when opening it in Android Studio, but only 40Mb with Shark.
1144*d9e8da70SAndroid Build Coastguard Worker
1145*d9e8da70SAndroid Build Coastguard Worker### Changes since 2.0 Beta 5
1146*d9e8da70SAndroid Build Coastguard Worker
1147*d9e8da70SAndroid Build Coastguard Worker* Shark CLI supports multiple connected devices [#1642](https://github.com/square/leakcanary/issues/1642)
1148*d9e8da70SAndroid Build Coastguard Worker* Fixed missing sources from Maven Central [#1643](https://github.com/square/leakcanary/issues/1643)
1149*d9e8da70SAndroid Build Coastguard Worker* Updated notification icon to avoid confusion with Twitter DM notifications, and added icons to bottom navigation bar [#1648](https://github.com/square/leakcanary/pull/1648)
1150*d9e8da70SAndroid Build Coastguard Worker* Automatic leak detection for support library fragments [#1611](https://github.com/square/leakcanary/pull/1611)
1151*d9e8da70SAndroid Build Coastguard Worker
1152*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1153*d9e8da70SAndroid Build Coastguard Worker[@AndreasBoehm](https://github.com/AndreasBoehm),
1154*d9e8da70SAndroid Build Coastguard Worker[@jrodbx](https://github.com/jrodbx),
1155*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau)
1156*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1157*d9e8da70SAndroid Build Coastguard Worker
1158*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0 Milestone](https://github.com/square/leakcanary/milestone/14) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-beta-5...v2.0).
1159*d9e8da70SAndroid Build Coastguard Worker
1160*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Beta 5 (2019-11-25)
1161*d9e8da70SAndroid Build Coastguard Worker
1162*d9e8da70SAndroid Build Coastguard Worker* Major bugfix: native gc roots were accidentally ignored in Beta 4, as a result some leaks were not found [#1634](https://github.com/square/leakcanary/issues/1634)
1163*d9e8da70SAndroid Build Coastguard Worker* Fixed Lint warning (`leak_canary_about_message` string triggered *multiple substitutions* warning) [#1630](https://github.com/square/leakcanary/issues/1630)
1164*d9e8da70SAndroid Build Coastguard Worker
1165*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1166*d9e8da70SAndroid Build Coastguard Worker[@DanEdgarTarget](https://github.com/DanEdgarTarget),
1167*d9e8da70SAndroid Build Coastguard Worker[@msfjarvis](https://github.com/msfjarvis),
1168*d9e8da70SAndroid Build Coastguard Worker[@PaulWoitaschek](https://github.com/pyricau),
1169*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1170*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers)
1171*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1172*d9e8da70SAndroid Build Coastguard Worker
1173*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-beta-5 Milestone](https://github.com/square/leakcanary/milestone/13) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-beta-4...v2.0-beta-5).
1174*d9e8da70SAndroid Build Coastguard Worker
1175*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Beta 4 (2019-11-18)
1176*d9e8da70SAndroid Build Coastguard Worker
1177*d9e8da70SAndroid Build Coastguard Worker* Improved string rendering for heap analysis results
1178*d9e8da70SAndroid Build Coastguard Worker* UX redesign [#1445](https://github.com/square/leakcanary/issues/1445)
1179*d9e8da70SAndroid Build Coastguard Worker* Support for pattern matching of native reference leaks [#1562](https://github.com/square/leakcanary/issues/1562)
1180*d9e8da70SAndroid Build Coastguard Worker* Added support for deobfuscation using Proguard mapping files in Shark [#1499](https://github.com/square/leakcanary/issues/1499). This isn't directly supported in LeakCanary yet.
1181*d9e8da70SAndroid Build Coastguard Worker* Added support for extracting metadata from the heap dump (see the [recipe](recipes.md#extracting-metadata-from-the-heap-dump)) [#1519](https://github.com/square/leakcanary/issues/1519)
1182*d9e8da70SAndroid Build Coastguard Worker* Improved auto disabling of LeakCanary in Unit and UI tests [#1552](https://github.com/square/leakcanary/issues/1552)
1183*d9e8da70SAndroid Build Coastguard Worker* Several performance improvements when parsing heap dumps
1184*d9e8da70SAndroid Build Coastguard Worker* Fixed several bugs and crashes
1185*d9e8da70SAndroid Build Coastguard Worker* Added new known leak patterns
1186*d9e8da70SAndroid Build Coastguard Worker
1187*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1188*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
1189*d9e8da70SAndroid Build Coastguard Worker[@BraisGabin](https://github.com/BraisGabin),
1190*d9e8da70SAndroid Build Coastguard Worker[@bric3](https://github.com/bric3),
1191*d9e8da70SAndroid Build Coastguard Worker[@elihart](https://github.com/elihart),
1192*d9e8da70SAndroid Build Coastguard Worker[@fernandospr](https://github.com/fernandospr),
1193*d9e8da70SAndroid Build Coastguard Worker[@flickator](https://github.com/flickator),
1194*d9e8da70SAndroid Build Coastguard Worker[@gabrysgab](https://github.com/gabrysgab),
1195*d9e8da70SAndroid Build Coastguard Worker[@JorgeDLS](https://github.com/JorgeDLS),
1196*d9e8da70SAndroid Build Coastguard Worker[@lannyf77](https://github.com/lannyf77),
1197*d9e8da70SAndroid Build Coastguard Worker[@msfjarvis](https://github.com/msfjarvis),
1198*d9e8da70SAndroid Build Coastguard Worker[@mzgreen](https://github.com/mzgreen),
1199*d9e8da70SAndroid Build Coastguard Worker[@ozmium](https://github.com/ozmium),
1200*d9e8da70SAndroid Build Coastguard Worker[@PaulWoitaschek](https://github.com/pyricau),
1201*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1202*d9e8da70SAndroid Build Coastguard Worker[@shelpy](https://github.com/shelpy),
1203*d9e8da70SAndroid Build Coastguard Worker[@vRallev](https://github.com/vRallev),
1204*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers)
1205*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1206*d9e8da70SAndroid Build Coastguard Worker
1207*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-beta-4 Milestone](https://github.com/square/leakcanary/milestone/12) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-beta-3...v2.0-beta-4).
1208*d9e8da70SAndroid Build Coastguard Worker
1209*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Beta 3 (2019-08-22)
1210*d9e8da70SAndroid Build Coastguard Worker
1211*d9e8da70SAndroid Build Coastguard Worker* Baseline memory usage for large hprofs divided by 3 and removed memory spikes [#1543](https://github.com/square/leakcanary/pull/1543)
1212*d9e8da70SAndroid Build Coastguard Worker* Fixed crash when LeakCanary is initialized from another process [#1529](https://github.com/square/leakcanary/issues/1529)
1213*d9e8da70SAndroid Build Coastguard Worker* Java local references are deprioritized to look for longer alternative paths [#1525](https://github.com/square/leakcanary/pull/1525)
1214*d9e8da70SAndroid Build Coastguard Worker* Fixed `JavaLocalPattern` not matching on Lollipop [#1524](https://github.com/square/leakcanary/pull/1524)
1215*d9e8da70SAndroid Build Coastguard Worker
1216*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1217*d9e8da70SAndroid Build Coastguard Worker[@Armaxis](https://github.com/Armaxis),
1218*d9e8da70SAndroid Build Coastguard Worker[@elihart](https://github.com/elihart),
1219*d9e8da70SAndroid Build Coastguard Worker[@emartynov](https://github.com/emartynov),
1220*d9e8da70SAndroid Build Coastguard Worker[@hmcgreevy-instil](https://github.com/hmcgreevy-instil),
1221*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau)
1222*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1223*d9e8da70SAndroid Build Coastguard Worker
1224*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-beta-3 Milestone](https://github.com/square/leakcanary/milestone/11) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-beta-2...v2.0-beta-3).
1225*d9e8da70SAndroid Build Coastguard Worker
1226*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Beta 2 (2019-08-02)
1227*d9e8da70SAndroid Build Coastguard Worker
1228*d9e8da70SAndroid Build Coastguard Worker* Fixed *Leak analysis failed: Object id not found in heap dump.* [#1516](https://github.com/square/leakcanary/issues/1516)
1229*d9e8da70SAndroid Build Coastguard Worker* 10x speed increase of hprof indexing on large heap dumps [#1520](https://github.com/square/leakcanary/pull/1520)
1230*d9e8da70SAndroid Build Coastguard Worker
1231*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1232*d9e8da70SAndroid Build Coastguard Worker[@kolphi](https://github.com/kolphi),
1233*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1234*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers)
1235*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1236*d9e8da70SAndroid Build Coastguard Worker
1237*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-beta-2 Milestone](https://github.com/square/leakcanary/milestone/10) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-beta-1...v2.0-beta-2).
1238*d9e8da70SAndroid Build Coastguard Worker
1239*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Beta 1 (2019-07-30)
1240*d9e8da70SAndroid Build Coastguard Worker
1241*d9e8da70SAndroid Build Coastguard Worker* New standalone library! [Shark](shark.md) is the heap analyzer that powers LeakCanary 2, and it can run in any Java VM. It comes with a [CLI](shark.md#shark-cli): you can now run `shark-cli analyze-process com.example.myapp` from your computer.
1242*d9e8da70SAndroid Build Coastguard Worker* New Heap Explorer directly on device! Open a Heap Analysis in LeakCanary, tap the options menu and select "Heap Explorer". This is still experimental and not very user friendly, contributions welcome!
1243*d9e8da70SAndroid Build Coastguard Worker* **Large API rewrite** to improve usability. If you used the alpha with a customized configuration, there are breaking changes. Of note: LeakSentry became [AppWatcher](/leakcanary/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/), RefWatcher became [ObjectWatcher](/leakcanary/api/leakcanary-object-watcher/leakcanary/-object-watcher/), AndroidExcludedRefs became [AndroidReferenceMatchers](/leakcanary/api/shark-android/shark/-android-reference-matchers/), AnalysisResultListener became [OnHeapAnalyzedListener](/leakcanary/api/leakcanary-android-core/leakcanary/-on-heap-analyzed-listener/), AndroidLeakTraceInspectors became [AndroidObjectInspectors](/leakcanary/api/shark-android/shark/-android-object-inspectors/).
1244*d9e8da70SAndroid Build Coastguard Worker* The entire API surface is now documented and the documentation is available on this website: see the **LeakCanary API** tab at the top.
1245*d9e8da70SAndroid Build Coastguard Worker* Removed the **dependency on Android X**. No more configuration issues! [#1462](https://github.com/square/leakcanary/issues/1462)
1246*d9e8da70SAndroid Build Coastguard Worker* Added **Proguard rules** for LeakCanary and ObjectWatcher. [#1500](https://github.com/square/leakcanary/pull/1500)
1247*d9e8da70SAndroid Build Coastguard Worker* Display LeakCanary version in the About screen. [#1448](https://github.com/square/leakcanary/issues/1448)
1248*d9e8da70SAndroid Build Coastguard Worker* Bug fixes, new reference matchers and object inspectors
1249*d9e8da70SAndroid Build Coastguard Worker
1250*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1251*d9e8da70SAndroid Build Coastguard Worker[@arctouch-carlosottoboni](https://github.com/arctouch-carlosottoboni),
1252*d9e8da70SAndroid Build Coastguard Worker[@jemaystermind](https://github.com/jemaystermind),
1253*d9e8da70SAndroid Build Coastguard Worker[@kushagrakumar27](https://github.com/kushagrakumar27),
1254*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1255*d9e8da70SAndroid Build Coastguard Worker[@snkashis](https://github.com/snkashis)
1256*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1257*d9e8da70SAndroid Build Coastguard Worker
1258*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-beta-1 Milestone](https://github.com/square/leakcanary/milestone/9) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-alpha-3...v2.0-beta-1).
1259*d9e8da70SAndroid Build Coastguard Worker
1260*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Alpha 3 (2019-07-04)
1261*d9e8da70SAndroid Build Coastguard Worker
1262*d9e8da70SAndroid Build Coastguard Worker* [#1401](https://github.com/square/leakcanary/pull/1401) LeakCanary can now import all hprof files created from prior LeakCanary versions.
1263*d9e8da70SAndroid Build Coastguard Worker* [#1414](https://github.com/square/leakcanary/pull/1414) New API: `RefWatcher.retainedInstances` which returns the instances that are currently considered retained.
1264*d9e8da70SAndroid Build Coastguard Worker* [#1419](https://github.com/square/leakcanary/pull/1419) New APIs: `LeakCanary.Config.maxStoredHeapDumps` (default 7) and `LeakCanary.Config.requestWriteExternalStoragePermission` (default false). LeakCanary won't ask for the external storage permission anymore by default.
1265*d9e8da70SAndroid Build Coastguard Worker* [#1338](https://github.com/square/leakcanary/issues/1338) API change: `LeakCanary.Config.exclusionsFactory` replaced with `LeakCanary.Config.knownReferences` (simpler use), `LeakCanary.Config.leakInspectors` and `LeakCanary.Config.labelers` merged into `LeakCanary.Config.leakTraceInspectors` which provides access to the entire leak trace as well as a new graph oriented API that replaces the low level hprof parser API.
1266*d9e8da70SAndroid Build Coastguard Worker* [#1382](https://github.com/square/leakcanary/issues/1382) LeakCanary now disables automatic heap dumping when running in AndroidX UI tests.
1267*d9e8da70SAndroid Build Coastguard Worker* [#1424](https://github.com/square/leakcanary/pull/1424) API rename: `RefWatcher.hasRetainedReferences` => `RefWatcher.hasRetainedInstances`, `RefWatcher.retainedReferenceCount` => `RefWatcher.retainedInstanceCount`, `RefWatcher.hasWatchedReferences` => `RefWatcher.hasWatchedInstances`, `RefWatcher.removeKeysRetainedBeforeHeapDump` => `RefWatcher.removeInstancesRetainedBeforeHeapDump`, `RefWatcher.clearWatchedReferences` => `RefWatcher.clearWatchedInstances`.
1268*d9e8da70SAndroid Build Coastguard Worker* [#1432](https://github.com/square/leakcanary/pull/1432) [#1438](https://github.com/square/leakcanary/pull/1438) [#1440](https://github.com/square/leakcanary/pull/1440) New "won't fix" leaks and leak trace inspectors
1269*d9e8da70SAndroid Build Coastguard Worker* [#1374](https://github.com/square/leakcanary/issues/1374) [#1364](https://github.com/square/leakcanary/issues/1364) [#1366](https://github.com/square/leakcanary/issues/1366) [#1417](https://github.com/square/leakcanary/issues/1417) [#1399](https://github.com/square/leakcanary/issues/#1399) [#1416](https://github.com/square/leakcanary/issues/1416) [#1407](https://github.com/square/leakcanary/issues/1407) [#1427](https://github.com/square/leakcanary/issues/1427) [#1385](https://github.com/square/leakcanary/issues/1385) Bug and crash fixes
1270*d9e8da70SAndroid Build Coastguard Worker
1271*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1272*d9e8da70SAndroid Build Coastguard Worker[@1step2hell](https://github.com/1step2hell),
1273*d9e8da70SAndroid Build Coastguard Worker[@afollestad](https://github.com/afollestad),
1274*d9e8da70SAndroid Build Coastguard Worker[@ansman](https://github.com/ansman),
1275*d9e8da70SAndroid Build Coastguard Worker[@bjdodson](https://github.com/bjdodson),
1276*d9e8da70SAndroid Build Coastguard Worker[@BraisGabin](https://github.com/BraisGabin),
1277*d9e8da70SAndroid Build Coastguard Worker[@EBfVince](https://github.com/EBfVince),
1278*d9e8da70SAndroid Build Coastguard Worker[@jaredsburrows](https://github.com/jaredsburrows),
1279*d9e8da70SAndroid Build Coastguard Worker[@pforhan](https://github.com/pforhan),
1280*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1281*d9e8da70SAndroid Build Coastguard Worker[@tellypresence](https://github.com/tellypresence),
1282*d9e8da70SAndroid Build Coastguard Worker[@wiyarmir](https://github.com/wiyarmir)
1283*d9e8da70SAndroid Build Coastguard Workerfor the contributions, bug reports and feature requests.
1284*d9e8da70SAndroid Build Coastguard Worker
1285*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-alpha-3 Milestone](https://github.com/square/leakcanary/milestone/8) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-alpha-2...v2.0-alpha-3).
1286*d9e8da70SAndroid Build Coastguard Worker
1287*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Alpha 2 (2019-05-21)
1288*d9e8da70SAndroid Build Coastguard Worker
1289*d9e8da70SAndroid Build Coastguard Worker* [#1040](https://github.com/square/leakcanary/pull/1040) Import and analyze hprof files from other devices
1290*d9e8da70SAndroid Build Coastguard Worker* [#1344](https://github.com/square/leakcanary/pull/1344) Computing retained size
1291*d9e8da70SAndroid Build Coastguard Worker* [#1325](https://github.com/square/leakcanary/pull/1325) New notification showing current count of retained instances
1292*d9e8da70SAndroid Build Coastguard Worker* [#1079](https://github.com/square/leakcanary/pull/1079) "Excluded" leaks have been renamed to "Won't fix" leaks to clarify meaning.
1293*d9e8da70SAndroid Build Coastguard Worker* [#1328](https://github.com/square/leakcanary/pull/1328) New leaks are called out in the UI.
1294*d9e8da70SAndroid Build Coastguard Worker* [#1327](https://github.com/square/leakcanary/pull/1327) LeakSentry can be enabled / disabled and is automatically disabled in non debuggable builds.
1295*d9e8da70SAndroid Build Coastguard Worker* [#1173](https://github.com/square/leakcanary/pull/1173) Experimental: now reporting leaks that only go through weak references (previously reported as "no path to instance")
1296*d9e8da70SAndroid Build Coastguard Worker* [#1339](https://github.com/square/leakcanary/pull/1339) Readded support for Thread name based exclusions
1297*d9e8da70SAndroid Build Coastguard Worker* [#1312](https://github.com/square/leakcanary/pull/1312) Fixed bug causing LeakCanary to stop detecting leaks after the app is killed.
1298*d9e8da70SAndroid Build Coastguard Worker* [#1310](https://github.com/square/leakcanary/pull/1310) [#1313](https://github.com/square/leakcanary/pull/1313) [#1314](https://github.com/square/leakcanary/pull/1314) [#1340](https://github.com/square/leakcanary/pull/1340) [#1337](https://github.com/square/leakcanary/pull/1337) Many API changes
1299*d9e8da70SAndroid Build Coastguard Worker* [#1296](https://github.com/square/leakcanary/pull/1296) [#1293](https://github.com/square/leakcanary/pull/1293) [#1306](https://github.com/square/leakcanary/pull/1306) [#1336](https://github.com/square/leakcanary/pull/1336) Fixed several crashes.
1300*d9e8da70SAndroid Build Coastguard Worker
1301*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1302*d9e8da70SAndroid Build Coastguard Worker[@forrestbice](https://github.com/forrestbice),
1303*d9e8da70SAndroid Build Coastguard Worker[@Foso](https://github.com/Foso),
1304*d9e8da70SAndroid Build Coastguard Worker[@Goddchen](https://github.com/Goddchen),
1305*d9e8da70SAndroid Build Coastguard Worker[@marcosholgado](https://github.com/marcosholgado),
1306*d9e8da70SAndroid Build Coastguard Worker[@orionlee](https://github.com/orionlee),
1307*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1308*d9e8da70SAndroid Build Coastguard Worker[@satoshun](https://github.com/satoshun),
1309*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers)
1310*d9e8da70SAndroid Build Coastguard Workerfor the contributions!
1311*d9e8da70SAndroid Build Coastguard Worker
1312*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-alpha-2 Milestone](https://github.com/square/leakcanary/milestone/7) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-alpha-1...v2.0-alpha-2).
1313*d9e8da70SAndroid Build Coastguard Worker
1314*d9e8da70SAndroid Build Coastguard Worker## Version 2.0 Alpha 1 (2019-04-23)
1315*d9e8da70SAndroid Build Coastguard Worker
1316*d9e8da70SAndroid Build Coastguard Worker![logo](images/logo-2.0-200px.png)
1317*d9e8da70SAndroid Build Coastguard Worker
1318*d9e8da70SAndroid Build Coastguard Worker* New [logo](https://github.com/square/leakcanary/wiki/FAQ#who-made-the-logo), thanks [@flickator](https://github.com/flickator)!
1319*d9e8da70SAndroid Build Coastguard Worker* Entirely rewritten to **100% Kotlin**
1320*d9e8da70SAndroid Build Coastguard Worker* Multiple leaks detected in one analysis
1321*d9e8da70SAndroid Build Coastguard Worker    * The heap is dumped when the app goes in the background, or when a minimum of 5 leaks is reached in the foreground.
1322*d9e8da70SAndroid Build Coastguard Worker* Leak grouping
1323*d9e8da70SAndroid Build Coastguard Worker    * Leaks that share similar causes are grouped in the UI.
1324*d9e8da70SAndroid Build Coastguard Worker    * New screens to see the list of groups and each group.
1325*d9e8da70SAndroid Build Coastguard Worker    * Improved leaktrace strings to highlight leak causes.
1326*d9e8da70SAndroid Build Coastguard Worker    * Leaks can be shared to Stack Overflow
1327*d9e8da70SAndroid Build Coastguard Worker* New library: **LeakSentry**.
1328*d9e8da70SAndroid Build Coastguard Worker    * Detects when objects are leaking and triggers LeakCanary
1329*d9e8da70SAndroid Build Coastguard Worker    * Can be used independently in production, for instance to report the number of leaking instances on an OutOfMemoryError crash.
1330*d9e8da70SAndroid Build Coastguard Worker* New heap parser
1331*d9e8da70SAndroid Build Coastguard Worker    * Uses **90% less memory and 6 times** faster than the prior heap parser.
1332*d9e8da70SAndroid Build Coastguard Worker    * Runs in the same process as the app on a low priority thread.
1333*d9e8da70SAndroid Build Coastguard Worker    * No more dependency on Perflib and TroveJ. New dependency on Okio.
1334*d9e8da70SAndroid Build Coastguard Worker    * The old parser is still available as `leakcanary-android-perflib` but will be removed after alpha.
1335*d9e8da70SAndroid Build Coastguard Worker* Labelers can add any string content to leak elements
1336*d9e8da70SAndroid Build Coastguard Worker* 0 code setup, just add the one debug dependency.
1337*d9e8da70SAndroid Build Coastguard Worker* Simpler configuration options
1338*d9e8da70SAndroid Build Coastguard Worker* Updated from support library to Android X
1339*d9e8da70SAndroid Build Coastguard Worker
1340*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1341*d9e8da70SAndroid Build Coastguard Worker[@BraisGabin](https://github.com/BraisGabin),
1342*d9e8da70SAndroid Build Coastguard Worker[@colinmarsch](https://github.com/colinmarsch),
1343*d9e8da70SAndroid Build Coastguard Worker[@jrodbx](https://github.com/jrodbx),
1344*d9e8da70SAndroid Build Coastguard Worker[@flickator](https://github.com/flickator),
1345*d9e8da70SAndroid Build Coastguard Worker[@JakeWharton](https://github.com/JakeWharton),
1346*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1347*d9e8da70SAndroid Build Coastguard Worker[@WhatsEmo](https://github.com/WhatsEmo)
1348*d9e8da70SAndroid Build Coastguard Workerfor the contributions!
1349*d9e8da70SAndroid Build Coastguard Worker
1350*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [2.0-alpha-1 Milestone](https://github.com/square/leakcanary/milestone/6) and the [full diff](https://github.com/square/leakcanary/compare/v1.6.3...v2.0-alpha-1).
1351*d9e8da70SAndroid Build Coastguard Worker
1352*d9e8da70SAndroid Build Coastguard Worker## Version 1.6.3 (2019-01-10)
1353*d9e8da70SAndroid Build Coastguard Worker
1354*d9e8da70SAndroid Build Coastguard Worker* [#1163](https://github.com/square/leakcanary/issues/1163) Fixed leaks being incorrectly classified as "no leak" due to missed GC Roots.
1355*d9e8da70SAndroid Build Coastguard Worker* [#1153](https://github.com/square/leakcanary/issues/1153) `LeakCanary.isInAnalyzerProcess` now correctly returns true in the analyzer process prior to any first leak (could be triggered by starting the leak result activity).
1356*d9e8da70SAndroid Build Coastguard Worker* [#1158](https://github.com/square/leakcanary/issues/1158) Stopped enabling DisplayLeakActivity when not using DisplayLeakService.
1357*d9e8da70SAndroid Build Coastguard Worker* [#1135](https://github.com/square/leakcanary/issues/1135) Fixed IndexOutOfBoundsException for leak traces of size 1.
1358*d9e8da70SAndroid Build Coastguard Worker* [#1163](https://github.com/square/leakcanary/issues/1163) Keep "no leak" heap dumps.
1359*d9e8da70SAndroid Build Coastguard Worker
1360*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1361*d9e8da70SAndroid Build Coastguard Worker[@KMaragh](https://github.com/KMaragh),
1362*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1363*d9e8da70SAndroid Build Coastguard Worker[@SebRut](https://github.com/SebRut)
1364*d9e8da70SAndroid Build Coastguard Workerfor the code contributions!
1365*d9e8da70SAndroid Build Coastguard Worker
1366*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [1.6.3 Milestone](https://github.com/square/leakcanary/milestone/5) and the [full diff](https://github.com/square/leakcanary/compare/v1.6.2...v1.6.3).
1367*d9e8da70SAndroid Build Coastguard Worker
1368*d9e8da70SAndroid Build Coastguard Worker
1369*d9e8da70SAndroid Build Coastguard Worker## Version 1.6.2 (2018-10-16)
1370*d9e8da70SAndroid Build Coastguard Worker
1371*d9e8da70SAndroid Build Coastguard Worker* [#1067](https://github.com/square/leakcanary/issues/1067) Fixed TransactionTooLargeException crash (leak analysis would never complete).
1372*d9e8da70SAndroid Build Coastguard Worker* [#1061](https://github.com/square/leakcanary/pull/1061) Detection of Fragment view leaks after Fragment#onDestroyView().
1373*d9e8da70SAndroid Build Coastguard Worker* [#1076](https://github.com/square/leakcanary/pull/1076) Added the FOREGROUND_SERVICE permission for Android P.
1374*d9e8da70SAndroid Build Coastguard Worker* [#1062](https://github.com/square/leakcanary/issues/1062) The LeakCanary toast now always shows correctly. It doesn't show if there is no activity in foreground.
1375*d9e8da70SAndroid Build Coastguard Worker* [#1115](https://github.com/square/leakcanary/issues/1115) Reenabled the DisplayLeakActivity icon on fresh installs.
1376*d9e8da70SAndroid Build Coastguard Worker* [#1100](https://github.com/square/leakcanary/pull/1100) Added nullability annotations to improve Kotlin support.
1377*d9e8da70SAndroid Build Coastguard Worker* Updates to excluded leaks ([commits](https://github.com/square/leakcanary/commits/v1.6.2/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java)).
1378*d9e8da70SAndroid Build Coastguard Worker* Updates to reachability inspectors ([commits](https://github.com/square/leakcanary/commits/v1.6.2/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidReachabilityInspectors.java)).
1379*d9e8da70SAndroid Build Coastguard Worker
1380*d9e8da70SAndroid Build Coastguard WorkerMany thanks to
1381*d9e8da70SAndroid Build Coastguard Worker[@fractalwrench](https://github.com/fractalwrench),
1382*d9e8da70SAndroid Build Coastguard Worker[@ZacSweers](https://github.com/ZacSweers),
1383*d9e8da70SAndroid Build Coastguard Worker[@Goddchen](https://github.com/Goddchen),
1384*d9e8da70SAndroid Build Coastguard Worker[@igokoro](https://github.com/igokoro),
1385*d9e8da70SAndroid Build Coastguard Worker[@IlyaGulya](https://github.com/IlyaGulya),
1386*d9e8da70SAndroid Build Coastguard Worker[@JakeWharton](https://github.com/JakeWharton),
1387*d9e8da70SAndroid Build Coastguard Worker[@javmarina](https://github.com/javmarina),
1388*d9e8da70SAndroid Build Coastguard Worker[@jokermonn](https://github.com/jokermonn),
1389*d9e8da70SAndroid Build Coastguard Worker[@jrodbx](https://github.com/jrodbx),
1390*d9e8da70SAndroid Build Coastguard Worker[@Parseus](https://github.com/Parseus),
1391*d9e8da70SAndroid Build Coastguard Worker[@pyricau](https://github.com/pyricau),
1392*d9e8da70SAndroid Build Coastguard Worker[@scottkennedy](https://github.com/scottkennedy)
1393*d9e8da70SAndroid Build Coastguard Workerfor the code contributions!
1394*d9e8da70SAndroid Build Coastguard Worker
1395*d9e8da70SAndroid Build Coastguard Worker### Public API changes
1396*d9e8da70SAndroid Build Coastguard Worker
1397*d9e8da70SAndroid Build Coastguard Worker* Subclasses of `AbstractAnalysisResultService` should now override `onHeapAnalyzed(@NonNull AnalyzedHeap analyzedHeap)` instead of `onHeapAnalyzed(@NonNull HeapDump heapDump, @NonNull AnalysisResult result)`
1398*d9e8da70SAndroid Build Coastguard Worker
1399*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [1.6.2 Milestone](https://github.com/square/leakcanary/milestone/4) and the [full diff](https://github.com/square/leakcanary/compare/v1.6.1...v1.6.2).
1400*d9e8da70SAndroid Build Coastguard Worker
1401*d9e8da70SAndroid Build Coastguard Worker## Version 1.6.1 (2018-06-21)
1402*d9e8da70SAndroid Build Coastguard Worker
1403*d9e8da70SAndroid Build Coastguard Worker* [#727](https://github.com/square/leakcanary/issues/727) Improved leak analysis: LeakCanary now identifies and highlights the potential causes of the leak.
1404*d9e8da70SAndroid Build Coastguard Worker* [#1011](https://github.com/square/leakcanary/issues/1011) We noticed that computing the retained heap size could take a long time, so it's now optional and off by default.
1405*d9e8da70SAndroid Build Coastguard Worker* [#633](https://github.com/square/leakcanary/pull/633) Support for detecting leaks in instrumentation tests ([see the wiki](https://github.com/square/leakcanary/wiki/Customizing-LeakCanary#running-leakcanary-in-instrumentation-tests)).
1406*d9e8da70SAndroid Build Coastguard Worker* [#985](https://github.com/square/leakcanary/pull/985) Ability to convert leak traces into stack traces for easy remote reporting ([see the wiki](uploading.md)).
1407*d9e8da70SAndroid Build Coastguard Worker* [#983](https://github.com/square/leakcanary/issues/983) Support for watching destroyed Fragments.
1408*d9e8da70SAndroid Build Coastguard Worker* [#846](https://github.com/square/leakcanary/issues/846) LeakCanary now uses foreground services and displays a notification when the analysis is in progress. This also fixes crashes when analyzing in background on O+.
1409*d9e8da70SAndroid Build Coastguard Worker* The LeakCanary icon (to start to DisplayLeakActivity) is now hidden by default, and only enabled after the first leak is found.
1410*d9e8da70SAndroid Build Coastguard Worker* [#775](https://github.com/square/leakcanary/issues/775) Fixed crash when sharing heap dumps on O+ and added a dependency to the support-core-utils library.
1411*d9e8da70SAndroid Build Coastguard Worker* [#930](https://github.com/square/leakcanary/pull/930) DisplayLeakActivity has a responsive icon.
1412*d9e8da70SAndroid Build Coastguard Worker* [#685](https://github.com/square/leakcanary/issues/685) Stopped doing IO on main thread in DisplayLeakActivity (fixes StrictMode errors).
1413*d9e8da70SAndroid Build Coastguard Worker* [#999](https://github.com/square/leakcanary/pull/999) Updated HAHA to 2.0.4, which uses Trove4j as an external dependency (from jcenter) instead of rebundling it. This is to clarify licences (Apache v2 vs LGPL 2.1).
1414*d9e8da70SAndroid Build Coastguard Worker* Several bug and crash fixes.
1415*d9e8da70SAndroid Build Coastguard Worker
1416*d9e8da70SAndroid Build Coastguard WorkerMany thanks to [@AdityaAnand1](https://github.com/AdityaAnand1), [@alhah](https://github.com/alhah), [@christxph](https://github.com/christxph), [@csoon03](https://github.com/csoon03), [@daqi](https://github.com/daqi), [@JakeWharton](https://github.com/JakeWharton), [@jankovd](https://github.com/jankovd), [@jrodbx](https://github.com/jrodbx), [@kurtisnelson](https://github.com/kurtisnelson), [@NightlyNexus](https://github.com/NightlyNexus), [@pyricau](https://github.com/pyricau), [@SalvatoreT](https://github.com/SalvatoreT), [@shmuelr](https://github.com/shmuelr), [@tokou](https://github.com/tokou), [@xueqiushi](https://github.com/xueqiushi)
1417*d9e8da70SAndroid Build Coastguard Worker for the code contributions!
1418*d9e8da70SAndroid Build Coastguard Worker
1419*d9e8da70SAndroid Build Coastguard WorkerNote: we made a 1.6 release but quickly followed up with 1.6.1 due to [#1058](https://github.com/square/leakcanary/issues/1058).
1420*d9e8da70SAndroid Build Coastguard Worker
1421*d9e8da70SAndroid Build Coastguard Worker### Public API changes
1422*d9e8da70SAndroid Build Coastguard Worker
1423*d9e8da70SAndroid Build Coastguard Worker* The installed ref watcher singleton is now available via `LeakCanary.installedRefWatcher()`
1424*d9e8da70SAndroid Build Coastguard Worker* `AnalysisResult.leakTraceAsFakeException()` returns an exception that can be used to report and group leak traces to a tool like Bugsnag or Crashlytics.
1425*d9e8da70SAndroid Build Coastguard Worker* New `InstrumentationLeakDetector` and `FailTestOnLeakRunListener` APIs for detecting leaks in instrumentation tests.
1426*d9e8da70SAndroid Build Coastguard Worker* New `Reachability.Inspector` and `RefWatcherBuilder.stethoscopeClasses()` API to establish reachability and help identify leak causes.
1427*d9e8da70SAndroid Build Coastguard Worker* Watching activities can be disabled with `AndroidRefWatcherBuilder.watchActivities(false)`, watching fragments can be disabled with `AndroidRefWatcherBuilder.watchFragments(false)`
1428*d9e8da70SAndroid Build Coastguard Worker* `LeakCanary.setDisplayLeakActivityDirectoryProvider()` is deprecated and replaced with `LeakCanary.setLeakDirectoryProvider()`
1429*d9e8da70SAndroid Build Coastguard Worker* New `RefWatcherBuilder.computeRetainedHeapSize()` API to enable the computing of the retained heap size (off by default).
1430*d9e8da70SAndroid Build Coastguard Worker
1431*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [1.6.1 Milestone](https://github.com/square/leakcanary/milestone/3) and the [full diff](https://github.com/square/leakcanary/compare/v1.5.4...v1.6.1).
1432*d9e8da70SAndroid Build Coastguard Worker
1433*d9e8da70SAndroid Build Coastguard Worker## Version 1.5.4 *(2017-09-22)*
1434*d9e8da70SAndroid Build Coastguard Worker
1435*d9e8da70SAndroid Build Coastguard Worker* Restore Java 7 compatibility in leakcanary-watcher
1436*d9e8da70SAndroid Build Coastguard Worker
1437*d9e8da70SAndroid Build Coastguard Worker## Version 1.5.3 *(2017-09-17)*
1438*d9e8da70SAndroid Build Coastguard Worker
1439*d9e8da70SAndroid Build Coastguard Worker* Fix broken 1.5.2 [build](https://github.com/square/leakcanary/issues/815)
1440*d9e8da70SAndroid Build Coastguard Worker* Convert leakcanary-watcher from Android library to Java library
1441*d9e8da70SAndroid Build Coastguard Worker* Disable finish animations in RequestStoragePermissionActivity
1442*d9e8da70SAndroid Build Coastguard Worker* Corrected README sample for Robolectric tests
1443*d9e8da70SAndroid Build Coastguard Worker
1444*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [full diff](https://github.com/square/leakcanary/compare/v1.5.2...v1.5.3).
1445*d9e8da70SAndroid Build Coastguard Worker
1446*d9e8da70SAndroid Build Coastguard Worker## Version 1.5.2 *(2017-08-09)*
1447*d9e8da70SAndroid Build Coastguard Worker
1448*d9e8da70SAndroid Build Coastguard Worker* New excluded leaks
1449*d9e8da70SAndroid Build Coastguard Worker* Move Leakcanary UI into leak analyzer process
1450*d9e8da70SAndroid Build Coastguard Worker* Ignore computing retained sizes for bitmaps on O+
1451*d9e8da70SAndroid Build Coastguard Worker* Add notification channel for persistent messages on O+
1452*d9e8da70SAndroid Build Coastguard Worker* Exclude permission activity from recents menu
1453*d9e8da70SAndroid Build Coastguard Worker* Updated README and sample for handling Robolectric tests
1454*d9e8da70SAndroid Build Coastguard Worker
1455*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [full diff](https://github.com/square/leakcanary/compare/v1.5.1...v1.5.2).
1456*d9e8da70SAndroid Build Coastguard Worker
1457*d9e8da70SAndroid Build Coastguard Worker## Version 1.5.1 *(2017-04-25)*
1458*d9e8da70SAndroid Build Coastguard Worker
1459*d9e8da70SAndroid Build Coastguard Worker* New excluded leaks
1460*d9e8da70SAndroid Build Coastguard Worker* Fix java.util.MissingFormatArgumentException in DisplayLeakService
1461*d9e8da70SAndroid Build Coastguard Worker* Separate task affinities for different apps
1462*d9e8da70SAndroid Build Coastguard Worker* Bump minSdk to 14
1463*d9e8da70SAndroid Build Coastguard Worker* Fix HahaHelper for O Preview
1464*d9e8da70SAndroid Build Coastguard Worker
1465*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [full diff](https://github.com/square/leakcanary/compare/v1.5...v1.5.1).
1466*d9e8da70SAndroid Build Coastguard Worker
1467*d9e8da70SAndroid Build Coastguard Worker## Version 1.5 *(2016-09-28)*
1468*d9e8da70SAndroid Build Coastguard Worker
1469*d9e8da70SAndroid Build Coastguard Worker* New excluded leaks
1470*d9e8da70SAndroid Build Coastguard Worker* Added `LeakCanary.isInAnalyzerProcess()` to the no-op jar
1471*d9e8da70SAndroid Build Coastguard Worker* Fixed several file access issues:
1472*d9e8da70SAndroid Build Coastguard Worker    * No more cleanup on startup, we rotate the heap dump files on every new heap dump.
1473*d9e8da70SAndroid Build Coastguard Worker    * LeakCanary now falls back to the app directory until it can write to the external storage.
1474*d9e8da70SAndroid Build Coastguard Worker* Leak notifications now each use a distinct notification instead of erasing each other.
1475*d9e8da70SAndroid Build Coastguard Worker* If LeakCanary can't perform a heap dump for any reason (e.g. analysis in progress, debugger attached), it retries later with an exponential backoff.
1476*d9e8da70SAndroid Build Coastguard Worker* Added confirmation dialog when user deletes all leaks.
1477*d9e8da70SAndroid Build Coastguard Worker* Replace the two LeakCanary configuration methods with a builder that provides more flexibility, see `LeakCanary.refWatcher()`.
1478*d9e8da70SAndroid Build Coastguard Worker
1479*d9e8da70SAndroid Build Coastguard WorkerFor more details, see the [full diff](https://github.com/square/leakcanary/compare/v1.4...v1.5).
1480*d9e8da70SAndroid Build Coastguard Worker
1481*d9e8da70SAndroid Build Coastguard Worker### Public API changes
1482*d9e8da70SAndroid Build Coastguard Worker
1483*d9e8da70SAndroid Build Coastguard Worker* New `HeapAnalyzer.findTrackedReferences()` method for headless analysis when you have no context on what leaked.
1484*d9e8da70SAndroid Build Coastguard Worker* Added `LeakCanary.isInAnalyzerProcess()` to the no-op jar
1485*d9e8da70SAndroid Build Coastguard Worker* Added `LeakCanary.refWatcher()` which returns an `AndroidRefWatcherBuilder` that extends `RefWatcherBuilder` and lets you fully customize the `RefWatcher` instance.
1486*d9e8da70SAndroid Build Coastguard Worker* Removed `LeakCanary.install(Application, Class)` and `LeakCanary.androidWatcher(Context, HeapDump.Listener, ExcludedRefs)`.
1487*d9e8da70SAndroid Build Coastguard Worker* Removed `R.integer.leak_canary_max_stored_leaks` and `R.integer.leak_canary_watch_delay_millis`, those can now be set via `LeakCanary.refWatcher()`.
1488*d9e8da70SAndroid Build Coastguard Worker* Updated the `LeakDirectoryProvider` API to centralize all file related responsibilities.
1489*d9e8da70SAndroid Build Coastguard Worker* `RefWatcher` is now constructed with a `WatchExecutor` which executes a `Retryable`, instead of an `Executor` that executes a `Runnable`.
1490*d9e8da70SAndroid Build Coastguard Worker* `HeapDumper.NO_DUMP` was renamed `HeapDumper.RETRY_LATER`
1491*d9e8da70SAndroid Build Coastguard Worker
1492*d9e8da70SAndroid Build Coastguard Worker## Version 1.4 *(2016-09-11)*
1493*d9e8da70SAndroid Build Coastguard Worker
1494*d9e8da70SAndroid Build Coastguard Worker* Fix false negative where GC root is of type android.os.Binder [#482](https://github.com/square/leakcanary/issues/482)
1495*d9e8da70SAndroid Build Coastguard Worker* Update HAHA to 2.0.3; clear compiler warnings [#563](https://github.com/square/leakcanary/issues/563)
1496*d9e8da70SAndroid Build Coastguard Worker* Correct some mistakes in German translation [#516](https://github.com/square/leakcanary/pull/516)
1497*d9e8da70SAndroid Build Coastguard Worker* Don't loop when storage permission denied [#422](https://github.com/square/leakcanary/issues/422)
1498*d9e8da70SAndroid Build Coastguard Worker* Remove old references to "__" prefixed resources [#477](https://github.com/square/leakcanary/pull/477)
1499*d9e8da70SAndroid Build Coastguard Worker* Fix permission crash for DisplayLeakActivity on M [#382](https://github.com/square/leakcanary/issues/382)
1500*d9e8da70SAndroid Build Coastguard Worker* Fix NPE when thread name not found in heap dump [#417](https://github.com/square/leakcanary/issues/417)
1501*d9e8da70SAndroid Build Coastguard Worker* Add version info to stacktrace [#473](https://github.com/square/leakcanary/issues/473)
1502*d9e8da70SAndroid Build Coastguard Worker
1503*d9e8da70SAndroid Build Coastguard Worker## Version 1.4-beta2 *(2016-03-23)*
1504*d9e8da70SAndroid Build Coastguard Worker
1505*d9e8da70SAndroid Build Coastguard Worker* Add reason for ignoring to analysis result [#365](https://github.com/square/leakcanary/issues/365).
1506*d9e8da70SAndroid Build Coastguard Worker* Lower memory usage when parsing heap dumps on M [#223](https://github.com/square/leakcanary/issues/223).
1507*d9e8da70SAndroid Build Coastguard Worker* Fix NPE in LeakCanaryInternals.isInServiceProcess() [#449](https://github.com/square/leakcanary/issues/449).
1508*d9e8da70SAndroid Build Coastguard Worker* New ignored Android SDK leaks [#297](https://github.com/square/leakcanary/issues/297),[#322](https://github.com/square/leakcanary/issues/322).
1509*d9e8da70SAndroid Build Coastguard Worker* Use leakcanary-android-no-op in test builds [#143](https://github.com/square/leakcanary/issues/143).
1510*d9e8da70SAndroid Build Coastguard Worker* Fixes to allow LeakCanary to work with ProGuard [#398](https://github.com/square/leakcanary/pull/398).
1511*d9e8da70SAndroid Build Coastguard Worker* Optimize png assets [#406](https://github.com/square/leakcanary/pull/406).
1512*d9e8da70SAndroid Build Coastguard Worker* Fix delete button not working on error views [#408](https://github.com/square/leakcanary/pull/408).
1513*d9e8da70SAndroid Build Coastguard Worker* Add German translation [#437](https://github.com/square/leakcanary/pull/437).
1514*d9e8da70SAndroid Build Coastguard Worker
1515*d9e8da70SAndroid Build Coastguard Worker## Version 1.4-beta1 *(2016-01-08)*
1516*d9e8da70SAndroid Build Coastguard Worker
1517*d9e8da70SAndroid Build Coastguard Worker* Switched to [HAHA 2.0.2](https://github.com/square/haha/blob/master/CHANGELOG.md#version-202-2015-07-20) with uses Perflib instead of MAT under the hood [#219](https://github.com/square/leakcanary/pull/219). This fixes crashes and improves speed a lot.
1518*d9e8da70SAndroid Build Coastguard Worker* We can now parse Android M heap dumps [#267](https://github.com/square/leakcanary/issues/267), although there are still memory issues (see [#223](https://github.com/square/leakcanary/issues/223)).
1519*d9e8da70SAndroid Build Coastguard Worker* Excluded leaks are now reported as well and available in the display leak activity.
1520*d9e8da70SAndroid Build Coastguard Worker* Added ProGuard configuration for [#132](https://github.com/square/leakcanary/issues/132).
1521*d9e8da70SAndroid Build Coastguard Worker* Many new ignored Android SDK leaks.
1522*d9e8da70SAndroid Build Coastguard Worker* Added excluded leaks to text report [#119](https://github.com/square/leakcanary/issues/119).
1523*d9e8da70SAndroid Build Coastguard Worker* Added LeakCanary SHA to text report [#120](https://github.com/square/leakcanary/issues/120).
1524*d9e8da70SAndroid Build Coastguard Worker* Added CanaryLog API to replace the logger: [#201](https://github.com/square/leakcanary/issues/201).
1525*d9e8da70SAndroid Build Coastguard Worker* Renamed all resources to begin with `leak_canary_` instead of `__leak_canary`[#161](https://github.com/square/leakcanary/pull/161)
1526*d9e8da70SAndroid Build Coastguard Worker* No crash when heap dump fails [#226](https://github.com/square/leakcanary/issues/226).
1527*d9e8da70SAndroid Build Coastguard Worker* Add retained size to leak reports [#162](https://github.com/square/leakcanary/issues/162).
1528*d9e8da70SAndroid Build Coastguard Worker
1529*d9e8da70SAndroid Build Coastguard Worker### Public API changes
1530*d9e8da70SAndroid Build Coastguard Worker
1531*d9e8da70SAndroid Build Coastguard Worker* AnalysisResult.failure is now a `Throwable` instead of an `Exception`. Main goal is to catch and correctly report OOMs while parsing.
1532*d9e8da70SAndroid Build Coastguard Worker* Added ARRAY_ENTRY to LeakTraceElement.Type for references through array entries.
1533*d9e8da70SAndroid Build Coastguard Worker* Renamed `ExcludedRefs` fields.
1534*d9e8da70SAndroid Build Coastguard Worker* Each `ExcludedRef` entry can now be ignored entirely or "kept only if no other path".
1535*d9e8da70SAndroid Build Coastguard Worker* Added support for ignoring all fields (static and non static) for a given class.
1536*d9e8da70SAndroid Build Coastguard Worker
1537*d9e8da70SAndroid Build Coastguard Worker## Version 1.3.1 *(2015-05-16)*
1538*d9e8da70SAndroid Build Coastguard Worker
1539*d9e8da70SAndroid Build Coastguard Worker* Heap dumps and analysis results are now saved on the sd card: [#21](https://github.com/square/leakcanary/issues/21).
1540*d9e8da70SAndroid Build Coastguard Worker* `ExcludedRef` and `AndroidExcludedRefs` are customizable: [#12](https://github.com/square/leakcanary/issues/12) [#73](https://github.com/square/leakcanary/issues/73).
1541*d9e8da70SAndroid Build Coastguard Worker* 7 new ignored Android SDK leaks: [#1](https://github.com/square/leakcanary/issues/1) [#4](https://github.com/square/leakcanary/issues/4) [#32](https://github.com/square/leakcanary/issues/32) [#89](https://github.com/square/leakcanary/pull/89) [#82](https://github.com/square/leakcanary/pull/82) [#97](https://github.com/square/leakcanary/pull/97).
1542*d9e8da70SAndroid Build Coastguard Worker* Fixed 3 crashes in LeakCanary: [#37](https://github.com/square/leakcanary/issues/37) [#46](https://github.com/square/leakcanary/issues/46) [#66](https://github.com/square/leakcanary/issues/66).
1543*d9e8da70SAndroid Build Coastguard Worker* Fixed StrictMode thread policy violations: [#15](https://github.com/square/leakcanary/issues/15).
1544*d9e8da70SAndroid Build Coastguard Worker* Updated `minSdkVersion` from `9` to `8`: [#57](https://github.com/square/leakcanary/issues/57).
1545*d9e8da70SAndroid Build Coastguard Worker* Added LeakCanary version name to `LeakCanary.leakInfo()`: [#49](https://github.com/square/leakcanary/issues/49).
1546*d9e8da70SAndroid Build Coastguard Worker* `leakcanary-android-no-op` is lighter, it does not depend on `leakcanary-watcher` anymore, only 2 classes now: [#74](https://github.com/square/leakcanary/issues/74).
1547*d9e8da70SAndroid Build Coastguard Worker* Adding field state details to the text leak trace.
1548*d9e8da70SAndroid Build Coastguard Worker* A Toast is displayed while the heap dump is in progress to warn that the UI will freeze: [#20](https://github.com/square/leakcanary/issues/49). You can customize the toast by providing your own layout named `__leak_canary_heap_dump_toast.xml` (e.g. you could make it an empty layout).
1549*d9e8da70SAndroid Build Coastguard Worker* If the analysis fails, the result and heap dump are kept so that it can be reported to LeakCanary: [#102](https://github.com/square/leakcanary/issues/102).
1550*d9e8da70SAndroid Build Coastguard Worker* Update to HAHA 1.3 to fix a 2 crashes [#3](https://github.com/square/leakcanary/issues/3) [46](https://github.com/square/leakcanary/issues/46)
1551*d9e8da70SAndroid Build Coastguard Worker
1552*d9e8da70SAndroid Build Coastguard Worker### Public API changes
1553*d9e8da70SAndroid Build Coastguard Worker
1554*d9e8da70SAndroid Build Coastguard Worker* When upgrading from 1.3 to 1.3.1, previously saved heap dumps will not be readable any more, but they won't be removed from the app directory. You should probably uninstall your app.
1555*d9e8da70SAndroid Build Coastguard Worker* Added `android.permission.WRITE_EXTERNAL_STORAGE` to `leakcanary-android` artifact.
1556*d9e8da70SAndroid Build Coastguard Worker* `LeakCanary.androidWatcher()` parameter types have changed (+ExcludedRefs).
1557*d9e8da70SAndroid Build Coastguard Worker* `LeakCanary.leakInfo()` parameter types have changed (+boolean)
1558*d9e8da70SAndroid Build Coastguard Worker* `ExcludedRef` is now serializable and immutable, instances can be created using `ExcludedRef.Builder`.
1559*d9e8da70SAndroid Build Coastguard Worker* `ExcludedRef` is available in `HeapDump`
1560*d9e8da70SAndroid Build Coastguard Worker* `AndroidExcludedRefs` is an enum, you can now pick the leaks you want to ignore in `AndroidExcludedRefs` by creating an `EnumSet` and calling `AndroidExcludedRefs.createBuilder()`.
1561*d9e8da70SAndroid Build Coastguard Worker* `AndroidExcludedRefs.createAppDefaults()` & `AndroidExcludedRefs.createAndroidDefaults()` return a `ExcludedRef.Builder`.
1562*d9e8da70SAndroid Build Coastguard Worker* `ExcludedRef` moved from `leakcanary-analyzer` to `leakcanary-watcher`
1563*d9e8da70SAndroid Build Coastguard Worker
1564*d9e8da70SAndroid Build Coastguard Worker## Version 1.3 *(2015-05-08)*
1565*d9e8da70SAndroid Build Coastguard Worker
1566*d9e8da70SAndroid Build Coastguard WorkerInitial release.
1567*d9e8da70SAndroid Build Coastguard Worker
1568*d9e8da70SAndroid Build Coastguard Worker### Dependencies
1569