Skip to content

LeakCanary should limit itself to a single heap dump + analysis at a time #2770

@pyricau

Description

@pyricau

Description

When using the worker manager setup, we can end up with several heap analysis running in parallel, and also the heap dumping while a heap analysis is in progress. This can put too much memory pressure on the current process as well as slow down analysis significantly as the N threads race for CPU resources.

Heap dumping is capped to once per minute, source: https://github.com/square/leakcanary/blob/main/leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/HeapDumpTrigger.kt#L421C5-L421C57

However, if the analysis isn't done before the minute is done, we'll then dump again, and start another analysis.

We could tag the work to check if the analysis is still in progress, although that's a bit tricky with the layers of abstraction. https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started/define-work

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions