You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/changelog.md
+25-2Lines changed: 25 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,31 @@
1
1
# Change Log
2
2
3
-
## Version 2.0 Alpha 3 (2019-07-04)
3
+
## Version 2.0 Beta 1 (2019-17-30)
4
+
5
+
LeakCanary 2 reached **beta status**: the internals and APIs are mostly stable.
6
+
7
+
Now is a great time to adopt it and provide feedback before the stable release. We're counting on you to find bugs and suggest improvements! Check out the new [Getting Started](https://square.github.io/leakcanary/getting_started) instructions and the [migration guide](https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/).
8
+
9
+
* 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.
10
+
* 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!
11
+
***Large API rewrite** to improve usability. If you used the alpha with a customized configuration, there are breaking changes. Of note: LeakSentry became [AppWatcher](/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/), RefWatcher became [ObjectWatcher](/api/leakcanary-object-watcher/leakcanary/-object-watcher/), AndroidExcludedRefs became [AndroidReferenceMatchers](/api/shark-android/shark/-android-reference-matchers/), AnalysisResultListener became [OnHeapAnalyzedListener](/api/leakcanary-android-core/leakcanary/-on-heap-analyzed-listener/), AndroidLeakTraceInspectors became [AndroidObjectInspectors](/api/shark-android/shark/-android-object-inspectors/).
12
+
* The entire API surface is now documented and the documentation is available on this website: try the search bar at the top and **LeakCanary API ∨** in the navigation menu.
13
+
* Removed the **dependency on Android X**. No more configuration issues! [#1462](https://github.com/square/leakcanary/issues/1462)
14
+
* Added **Proguard rules** for LeakCanary and ObjectWatcher. [#1500](https://github.com/square/leakcanary/pull/1500)
15
+
* Display LeakCanary version in the About screen. [#1448](https://github.com/square/leakcanary/issues/1448)
16
+
* Bug fixes, new reference matchers and object inspectors
for the contributions, bug reports and feature requests.
4
25
5
-
**Thanks for testing the alpha**, we're counting on you to help us find bugs and suggest improvements! Check out the new [Getting Started](https://square.github.io/leakcanary/getting_started) instructions and the [migration guide](https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/).
26
+
For more details, see the [2.0-beta-1 Milestone](https://github.com/square/leakcanary/milestone/1) and the [full diff](https://github.com/square/leakcanary/compare/v2.0-alpha-3...v2.0-beta-1).
27
+
28
+
## Version 2.0 Alpha 3 (2019-07-04)
6
29
7
30
*[#1401](https://github.com/square/leakcanary/pull/1401) LeakCanary can now import all hprof files created from prior LeakCanary versions.
8
31
*[#1414](https://github.com/square/leakcanary/pull/1414) New API: `RefWatcher.retainedInstances` which returns the instances that are currently considered retained.
Copy file name to clipboardExpand all lines: docs/faq.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
3
3
## Can a leak be caused by the Android SDK?
4
4
5
-
Yes. There are a number of known memory leaks that have been fixed over time in AOSP as well as in manufacturer implementations. When such a leak occurs, there is little you can do as an app developer to fix it. For that reason, LeakCanary has a built-in list of known Android leaks to ignore: [AndroidExcludedRefs.kt](https://github.com/square/leakcanary/blob/master/leakcanary-analyzer/src/main/java/leakcanary/AndroidExcludedRefs.kt).
5
+
Yes. There are a number of known memory leaks that have been fixed over time in AOSP as well as in manufacturer implementations. When such a leak occurs, there is little you can do as an app developer to fix it. For that reason, LeakCanary has a built-in list of known Android leaks to ignore: [AndroidReferenceMatchers](/api/shark-android/shark/-android-reference-matchers/).
6
6
7
7
If you find a new one, please [create an issue](https://github.com/square/leakcanary/issues/new/choose) and follow these steps:
8
8
9
9
1. Provide the entire leak trace information (reference key, device, etc), and use backticks (`) for formatting.
10
-
2. Read the AOSP source for that version of Android, and try to figure out why it happens. You can easily navigate through SDK versions [android/platform_frameworks_base](https://github.com/android/platform_frameworks_base).
10
+
2. Read the AOSP source for that version of Android, and try to figure out why it happens. You can easily navigate through SDK versions by switching branches on the GitHub mirror: [android/platform_frameworks_base](https://github.com/android/platform_frameworks_base).
11
11
3. Check if it happens on the latest version of Android, and otherwise use blame to find when it was fixed.
12
12
4. If it's still happening, build a simple repro case.
13
13
5. File an issue on [b.android.com](http://b.android.com) with the leak trace and the repro case.
@@ -46,7 +46,7 @@ Update your dependencies to the latest SNAPSHOT (see [build.gradle](https://gith
Copy file name to clipboardExpand all lines: docs/fundamentals.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ The chain of references from the GC root to the leaking instance is what is prev
143
143
│ View.mWindowAttachCount=1
144
144
```
145
145
146
-
LeakCanary runs heuristics to determine the lifecycle state of the nodes of the leak trace, and therefore whether they are leaking or not. For example, if a view has `View#mAttachInfo = null` and `mParent != null` then it is detached yet has a parent, so that view is probably leaking. In the leak trace, for each node you'll see `Leaking: YES / NO / UNKNOWN` with an explanation in parenthesis. LeakCanary can also surface extra information about the state of a node, e.g. `View.mWindowAttachCount=1`. LeakCanary comes with a set of default heuristics ([AndroidObjectInspectors](/api/shark-android/shark/-android-object-inspectors/), you can add your own heuristics by updating [LeakCanary.Config.objectInspectors](/api/leakcanary-android-core/leakcanary/-leak-canary/-config/object-inspectors/).
146
+
LeakCanary runs heuristics to determine the lifecycle state of the nodes of the leak trace, and therefore whether they are leaking or not. For example, if a view has `View#mAttachInfo = null` and `mParent != null` then it is detached yet has a parent, so that view is probably leaking. In the leak trace, for each node you'll see `Leaking: YES / NO / UNKNOWN` with an explanation in parenthesis. LeakCanary can also surface extra information about the state of a node, e.g. `View.mWindowAttachCount=1`. LeakCanary comes with a set of default heuristics: [AndroidObjectInspectors](/api/shark-android/shark/-android-object-inspectors/). You can add your own heuristics by updating [LeakCanary.Config.objectInspectors](/api/leakcanary-android-core/leakcanary/-leak-canary/-config/object-inspectors/) (see the [recipe](recipes.md#identifying-leaking-objects-and-labeling-objects)).
Copy file name to clipboardExpand all lines: docs/getting_started.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,10 @@ dependencies {
9
9
}
10
10
```
11
11
12
-
**That's it, there is no code change needed!**[Here's why](faq.md#how-does-leakcanary-get-installed-by-only-adding-a-dependency). LeakCanary will automatically show a notification when a memory leak is detected in debug builds.
12
+
**That's it, there is no code change needed!** LeakCanary will automatically show a notification when a memory leak is detected in debug builds.
13
13
14
14
What's next?
15
15
16
16
* Learn the [Fundamentals](fundamentals.md)
17
17
* Try the [code recipes](recipes.md)
18
-
* Read the [FAQ](faq.md)
18
+
* Read the [FAQ](faq.md), e.g. [How does LeakCanary get installed by only adding a dependency?](faq.md#how-does-leakcanary-get-installed-by-only-adding-a-dependency)
Copy file name to clipboardExpand all lines: docs/recipes.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ If you think a recipe might be missing or you're not sure that what you're tryin
4
4
5
5
## Configuring AppWatcher in `object-watcher-android`
6
6
7
-
AppWatcher is in charge of detecting retained objects. Its configuration can be updated at any time by replacing `AppWatcher.config`:
7
+
AppWatcher is in charge of detecting retained objects. Its configuration can be updated at any time by replacing [AppWatcher.config](/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/config/):
In your application, you may have other objects with a lifecycle, such as fragments, services, Dagger components, etc. Use `AppWatcher.objectWatcher` to watch instances that should be garbage collected:
30
+
In your application, you may have other objects with a lifecycle, such as fragments, services, Dagger components, etc. Use [AppWatcher.objectWatcher](/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/object-watcher/) to watch instances that should be garbage collected:
31
31
32
32
```kotlin
33
33
classMyService : Service {
@@ -118,7 +118,7 @@ res/
118
118
119
119
You can change the default behavior to upload the analysis result to a server of your choosing.
120
120
121
-
Create a custom `AnalysisResultListener` that delegates to the default:
121
+
Create a custom [OnHeapAnalyzedListener](/api/leakcanary-android-core/leakcanary/-on-heap-analyzed-listener/) that delegates to [DefaultOnHeapAnalyzedListener](/api/leakcanary-android-core/leakcanary/-default-on-heap-analyzed-listener/):
122
122
123
123
```kotlin
124
124
classLeakUploader : OnHeapAnalyzedListener {
@@ -134,7 +134,7 @@ class LeakUploader : OnHeapAnalyzedListener {
134
134
}
135
135
```
136
136
137
-
Set `analysisResultListener` on the LeakCanaryconfig:
137
+
Set [LeakCanary.config.onHeapAnalyzedListener](/api/leakcanary-android-core/leakcanary/-leak-canary/-config/on-heap-analyzed-listener/):
Shark is the heap analyzer that powers LeakCanary. It's a standalone heap analyzer Kotlin library that can run in Java and Android VMs at **high speed** with a **low memory footprint**. It can analyze both Android and Java VM hprof files.
10
+
Shark is the heap analyzer that powers LeakCanary 2. It's a Kotlin standalone heap analysis library that runs at **high speed** with a **low memory footprint**.
11
11
12
-
Shark is released as several distinct libraries:
12
+
Shark is released in layers:
13
13
14
-
*`Shark Hprof`: Read and write records in hprof files
1.**Shark Hprof**: Read and write records in hprof files.
15
+
2.**Shark Graph**: Navigate the heap object graph.
16
+
3.**Shark**: Generate heap analysis reports.
17
+
4.**Shark Android**: Android heuristics to generate tailored heap analysis reports.
18
+
5.**Shark CLI**: Analyze the heap of debuggable apps installed on an Android device connected to your desktop. The output is similar to the output of LeakCanary, except you don't have to add the LeakCanary dependency to your app.
19
+
6.**LeakCanary**: Builds on top. It automatically watches destroyed activities and fragments, triggers a heap dump, runs Shark Android and then displays the result.
18
20
19
-
Shark is also released as a CLI tool, `Shark CLI`.
21
+
A few more things:
20
22
21
-
## Example usage
23
+
* Shark is built on top of Okio. Okio makes it easy to parse heap dumps efficiently.
24
+
* Shark is a 100% Kotlin library, and Kotlin is essential to its design, because Shark relies heavily on sealed classes and sequences to save memory.
25
+
* Shark has the unique ability to help narrow down the cause of memory leaks through platform specific [heuristics](fundamentals.md#heuristics-and-labels).
26
+
* Shark is heavily tested (80% test coverage).
27
+
* Shark can run in both Java and Android VMs, with no other dependency than Okio and Kotlin.
28
+
* Shark can analyze both Java and Android VM hprof files.
22
29
23
-
### Reading records in a hprof file with shark-hprof
30
+
## Shark CLI
31
+
32
+
The Shark Command Line Interface (CLI) enables you to analyze heaps directly from your computer. It can dump the heap of an app installed on a connected Android device, analyze it, and even strip a heap dump of any sensitive data (e.g. PII, passwords or encryption keys) which is useful when sharing a heap dump.
33
+
34
+
Download it [here](https://github.com/square/leakcanary/releases/download/v2.0-beta-1/shark-cli-2.0-beta-1.zip)!
Copy file name to clipboardExpand all lines: docs/upgrading-to-leakcanary-2.0.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ val objectWatcher: ObjectWatcher = AppWatcher.objectWatcher
72
72
73
73
## Compile errors because RefWatcher is used in release code
74
74
75
-
If you were using `RefWatcher` in non debug code, you now get a compile error because the no-op artifact is gone. `ObjectWatcher` now lives in the `object-watcher` artifact, which is suitable for production. You have two options:
75
+
If you were using `RefWatcher` in non debug code, you now get a compile error because the no-op artifact is gone. [ObjectWatcher](/api/leakcanary-object-watcher/leakcanary/-object-watcher/) now lives in the `object-watcher` artifact, which is suitable for production. You have two options:
76
76
77
77
### Option 1: Add `object-watcher-android` to release builds.
78
78
@@ -82,7 +82,7 @@ dependencies {
82
82
}
83
83
```
84
84
85
-
* It will automatically keep weak references to destroyed activities, fragments, and any instance you pass to `ObjectWatcher`.
85
+
* It will automatically keep weak references to destroyed activities, fragments, and any instance you pass to [AppWatcher.objectWatcher](/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/object-watcher/).
86
86
* It will not trigger heap dumps or anything else that LeakCanary does.
87
87
* It's very little code and should have a no impact on your release app.
88
88
* You can use it to count how many objects are retained, for example to add metadata to OutOfMemoryError crashes:
@@ -112,7 +112,7 @@ class RealObjectWatcher : MaybeObjectWatcher {
112
112
}
113
113
```
114
114
115
-
Use MaybeObjectWatcher.None in release code and RealObjectWatcher in debug code.
115
+
Use `MaybeObjectWatcher.None` in release code and `RealObjectWatcher` in debug code.
116
116
117
117
## Configuring LeakCanary
118
118
@@ -131,7 +131,7 @@ public class DebugExampleApplication extends ExampleApplication {
131
131
132
132
### Now
133
133
134
-
AppWatcher is in charge of detecting retained objects. Its configuration can be updated at any time by replacing `AppWatcher.config`:
134
+
AppWatcher is in charge of detecting retained objects. Its configuration can be updated at any time by replacing [AppWatcher.config](/api/leakcanary-object-watcher-android/leakcanary/-app-watcher/config/):
@@ -143,7 +143,7 @@ class DebugExampleApplication : ExampleApplication() {
143
143
}
144
144
```
145
145
146
-
LeakCanary is in charge of taking heap dumps and analyzing them. Its configuration can be updated at any time by replacing `LeakCanary.config`:
146
+
LeakCanary is in charge of taking heap dumps and analyzing them. Its configuration can be updated at any time by replacing [LeakCanary.config](/api/leakcanary-android-core/leakcanary/-leak-canary/config/):
0 commit comments