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