Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1614)

Unified Diff: tools/memory_inspector/memory_inspector/frontends/background_tasks.py

Issue 549313006: [Android] memory_inspector: move to libheap_profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mi3_prebuilts
Patch Set: Add prebuilts Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/memory_inspector/memory_inspector/frontends/background_tasks.py
diff --git a/tools/memory_inspector/memory_inspector/frontends/background_tasks.py b/tools/memory_inspector/memory_inspector/frontends/background_tasks.py
index 27d08be36b84ea4e5ad015dbaa7f2a083a8c0558..96f03aaecc5fbc4263e068c1ac5f3e66c86a5570 100644
--- a/tools/memory_inspector/memory_inspector/frontends/background_tasks.py
+++ b/tools/memory_inspector/memory_inspector/frontends/background_tasks.py
@@ -90,14 +90,25 @@ def TracerMain_(log, storage_path, backend_name, device_id, pid, interval,
completion = 80 * i / count
log.put((completion, 'Dumping trace %d of %d' % (i, count)))
archive.StartNewSnapshot()
- mmaps = process.DumpMemoryMaps()
- log.put((completion, 'Dumped %d memory maps' % len(mmaps)))
- archive.StoreMemMaps(mmaps)
- if trace_native_heap:
- nheap = process.DumpNativeHeap()
- log.put((completion, 'Dumped %d native allocs' % len(nheap.allocations)))
- archive.StoreNativeHeap(nheap)
- heaps_to_symbolize += [nheap]
+ # Freeze the process, so that the mmaps and the heap dump are consistent.
+ process.Freeze()
+ try:
+ if trace_native_heap:
+ nheap = process.DumpNativeHeap()
+ log.put((completion,
+ 'Dumped %d native allocations' % len(nheap.allocations)))
+
+ # TODO(primiano): memdump has the bad habit of sending SIGCONT to the
+ # process. Fix that, so we are the only one in charge of controlling it.
+ mmaps = process.DumpMemoryMaps()
+ log.put((completion, 'Dumped %d memory maps' % len(mmaps)))
+ archive.StoreMemMaps(mmaps)
+
+ if trace_native_heap:
+ archive.StoreNativeHeap(nheap)
+ heaps_to_symbolize += [nheap]
+ finally:
+ process.Unfreeze()
if i < count:
time.sleep(interval)

Powered by Google App Engine
This is Rietveld 408576698