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

Initial notification when generating Heap Dump #20

Closed
jaggernod opened this issue May 10, 2015 · 2 comments · Fixed by #96
Closed

Initial notification when generating Heap Dump #20

jaggernod opened this issue May 10, 2015 · 2 comments · Fixed by #96

Comments

@jaggernod
Copy link

Creating and processing a Heap Dump does freeze UI for a significant amount of time for large heap dumps.
It's 8 seconds for me during which the application is unresponsive.
Of course the users won't be affected by that but our QA will.

Do you think it is a good idea to show a Toast (or any other notification) when you start the process. Will make users more aware why app is unresponsive.

@pyricau
Copy link
Member

pyricau commented May 14, 2015

That's an interesting idea. While it's not built in LeakCanary at the moment, you should be able to implement it easily.

  1. Create a new implementation of HeapDumper similar to AndroidHeapDumper and setup the RefWatcher using that (look at the static methods in LeakCanary).
  2. AndroidHeapDumper.dumpHeap() is called from a background thread. You could post to the main thread to tell your app to show some UI and block in dumpHeap() until that post is handled. Maybe wait for main thread idle.
  3. Perform the heap dump.
  4. Notify on the main thread that the heap dump has been performed.

I don't know if this is something we should build into LeakCanary or not, and I'm also not sure what the best sort of notification would be for that usage (notification, toast, adding a view to the hierarchy).. thoughts?

@pyricau
Copy link
Member

pyricau commented May 14, 2015

I'm currently thinking of doing this only for the duration of the call to Debug.dumpHprofData().

However, before that we do a GC, and after that we perform the analysis in a separate process. The GC can take ~0.5s, while the heap dump can take ~3s. The analysis can take a minute.

pyricau added a commit that referenced this issue May 15, 2015
pyricau added a commit that referenced this issue May 15, 2015
pyricau added a commit that referenced this issue May 15, 2015
pyricau added a commit that referenced this issue May 15, 2015
Display a Toast while heap dump is in progress. Fixes #20.
Yky pushed a commit to Yky/leakcanary that referenced this issue Feb 21, 2016
Yky pushed a commit to Yky/leakcanary that referenced this issue Feb 21, 2016
Display a Toast while heap dump is in progress. Fixes square#20.
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 a pull request may close this issue.

2 participants