Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heapDumpDurationMillis to HeapAnalysis #1931

Merged
merged 2 commits into from
Sep 18, 2020
Merged

Conversation

chao2zhang
Copy link
Contributor

On Android 11, we have experienced slow heap dumps as described in https://issuetracker.google.com/issues/168634429.
The heap dump was still relatively quick for a vanilla sampe project, so I would like to contribute to leak canary to verify the heap dump in a large-scale app to support the arguments.

Implementation-wise, I used -1 as an invalid duration and the corresponding formatted text would be "UNKNOWN". If the duration for the heap dump is valid, the text would be like "42 ms".

I have tested this patch manually by installing on my device as well as running ./gradlew test. If there are other steps I need to take for testing, please let me know.

@CLAassistant
Copy link

CLAassistant commented Sep 17, 2020

CLA assistant check
All committers have signed the CLA.

@@ -65,12 +65,14 @@ internal class AndroidHeapDumper(
val toast = waitingForToast.get()

return try {
Debug.dumpHprofData(heapDumpFile.absolutePath)
val durationMillis = measureTimeMillis {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

measureTimeMillis is based on System.currentTimeMillis() which isn't recommended for measuring durations (not monotonically increasing).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have switched to a new util method which calls SystemClock.uptimeMillis()

Copy link
Member

@pyricau pyricau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

It's looking really good, though I asked for a few changes.

Related issue: #1928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants