diff options
author | Brian Carlstrom <bdc@google.com> | 2011-02-24 10:43:13 -0800 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2011-02-24 10:43:13 -0800 |
commit | ed94c622ac91edc38c9f87d5e1508bfae1b26c95 (patch) | |
tree | 8afcf7bf03cacd0a11ad61f2f49a854186c784f8 /dalvik/src/main | |
parent | 217766d68f160dd03def5d5f983d5330c24a3ed7 (diff) | |
download | libcore-ed94c622ac91edc38c9f87d5e1508bfae1b26c95.zip libcore-ed94c622ac91edc38c9f87d5e1508bfae1b26c95.tar.gz libcore-ed94c622ac91edc38c9f87d5e1508bfae1b26c95.tar.bz2 |
Move state from Sampler to SamplingProfiler that needs to be preserved across a profiler restart
Change-Id: I39acb54cca5b98c7f147e2d9cc083c6ab4b17707
Diffstat (limited to 'dalvik/src/main')
-rw-r--r-- | dalvik/src/main/java/dalvik/system/SamplingProfiler.java | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/dalvik/src/main/java/dalvik/system/SamplingProfiler.java b/dalvik/src/main/java/dalvik/system/SamplingProfiler.java index 7946c02..b2ee6fb 100644 --- a/dalvik/src/main/java/dalvik/system/SamplingProfiler.java +++ b/dalvik/src/main/java/dalvik/system/SamplingProfiler.java @@ -1376,6 +1376,36 @@ public final class SamplingProfiler { */ private final ThreadSet threadSet; + /* + * Real hprof output examples don't start the thread and trace + * identifiers at one but seem to start at these arbitrary + * constants. It certainly seems useful to have relatively unique + * identifers when manual searching hprof output. + */ + private int nextThreadId = 200001; + private int nextStackTraceId = 300001; + private int nextObjectId = 1; + + /** + * The threads currently known to the profiler for detecting + * thread start and end events. + */ + private Thread[] currentThreads = new Thread[0]; + + /** + * Map of currently active threads to their identifiers. When + * threads disappear they are removed and only referenced by their + * identifiers to prevent retaining garbage threads. + */ + private final Map<Thread, Integer> threadIds = new HashMap<Thread, Integer>(); + + /** + * Mutable StackTrace that is used for probing stackTraces Map + * without allocating a StackTrace. If addStackTrace needs to + * be thread safe, this would need to be reconsidered. + */ + private final HprofData.StackTrace mutableStackTrace = new HprofData.StackTrace(); + /** * Create a sampling profiler that collects stacks with the * specified depth from the threads specified by the specified @@ -1561,31 +1591,6 @@ public final class SamplingProfiler { private class Sampler extends TimerTask { private Thread timerThread; - private Thread[] currentThreads = new Thread[0]; - - /* - * Real hprof output examples don't start the thread and trace - * identifiers at one but seem to start at these arbitrary - * constants. It certainly seems useful to have relatively unique - * identifers when manual searching hprof output. - */ - private int nextThreadId = 200001; - private int nextStackTraceId = 300001; - private int nextObjectId = 1; - - /** - * Map of currently active threads to their identifiers. When - * threads disappear they are removed and only referenced by their - * identifiers to prevent retaining garbage threads. - */ - private final Map<Thread, Integer> threadIds = new HashMap<Thread, Integer>(); - - /** - * Mutable StackTrace that is used for probing stackTraces Map - * without allocating a StackTrace. If addStackTrace needs to - * be thread safe, this would need to be reconsidered. - */ - private final HprofData.StackTrace mutableStackTrace = new HprofData.StackTrace(); public void run() { if (timerThread == null) { |