Allow concurrent tools/java_heap_dump.
Change-Id: Ib3456499ce36b508ed1d2a12c66006e283928ac1
diff --git a/tools/java_heap_dump b/tools/java_heap_dump
index 03abb01..7fc8540 100755
--- a/tools/java_heap_dump
+++ b/tools/java_heap_dump
@@ -24,6 +24,7 @@
import sys
import tempfile
import time
+import uuid
NULL = open(os.devnull)
@@ -61,9 +62,11 @@
}}
"""
+UUID = str(uuid.uuid4())[-6:]
+PROFILE_PATH = '/data/misc/perfetto-traces/java-profile-' + UUID
+
PERFETTO_CMD = ('CFG=\'{cfg}\'; echo ${{CFG}} | '
- 'perfetto --txt -c - -o '
- '/data/misc/perfetto-traces/java-profile-{user} -d')
+ 'perfetto --txt -c - -o ' + PROFILE_PATH + ' -d')
def main(argv):
@@ -189,8 +192,10 @@
time.sleep(1)
subprocess.check_call(
- ['adb', 'pull', '/data/misc/perfetto-traces/java-profile-{}'.format(user),
- output_file], stdout=NULL)
+ ['adb', 'pull', PROFILE_PATH, output_file], stdout=NULL)
+
+ subprocess.check_call(
+ ['adb', 'shell', 'rm', PROFILE_PATH], stdout=NULL)
print("Wrote profile to {}".format(output_file))
print("This can be viewed using https://ui.perfetto.dev.")