public final class

VMDebug

extends Object
java.lang.Object
   ↳ dalvik.system.VMDebug

This class is deprecated.
this is an internal Dalvik class that is not appropriate for general use. It will be removed from the public API in a future release.

Class Overview

Provides access to some VM-specific debug features. Though this class and many of its members are public, this class is meant to be wrapped in a more friendly way for use by application developers. On the Android platform, the recommended way to access this functionality is through the class android.os.Debug.

Summary

Constants
String DEFAULT_METHOD_TRACE_FILE_NAME This constant is deprecated. only used in one place, which is unused and deprecated
int KIND_ALL_COUNTS
int KIND_GLOBAL_ALLOCATED_BYTES
int KIND_GLOBAL_ALLOCATED_OBJECTS
int KIND_GLOBAL_CLASS_INIT_COUNT
int KIND_GLOBAL_CLASS_INIT_TIME
int KIND_GLOBAL_EXT_ALLOCATED_BYTES
int KIND_GLOBAL_EXT_ALLOCATED_OBJECTS
int KIND_GLOBAL_EXT_FREED_BYTES
int KIND_GLOBAL_EXT_FREED_OBJECTS
int KIND_GLOBAL_FREED_BYTES
int KIND_GLOBAL_FREED_OBJECTS
int KIND_GLOBAL_GC_INVOCATIONS
int KIND_THREAD_ALLOCATED_BYTES
int KIND_THREAD_ALLOCATED_OBJECTS
int KIND_THREAD_CLASS_INIT_COUNT
int KIND_THREAD_CLASS_INIT_TIME
int KIND_THREAD_EXT_ALLOCATED_BYTES
int KIND_THREAD_EXT_ALLOCATED_OBJECTS
int KIND_THREAD_EXT_FREED_BYTES
int KIND_THREAD_EXT_FREED_OBJECTS
int KIND_THREAD_FREED_BYTES
int KIND_THREAD_FREED_OBJECTS
int KIND_THREAD_GC_INVOCATIONS
int TRACE_COUNT_ALLOCS flag for startMethodTracing(), which adds the results from startAllocCounting to the trace key file.
Public Methods
static void dumpHprofData(String fileName)
Dump "hprof" data to the specified file.
static int getAllocCount(int kind)
static void getInstructionCount(int[] counts)
static int getLoadedClassCount()
Gets the number of loaded classes.
static boolean isDebuggerConnected()
Determines if a debugger is currently attached.
static boolean isDebuggingEnabled()
Determines if debugging is enabled in this VM.
static long lastDebuggerActivity()
Returns the time since the last known debugger activity.
static void printLoadedClasses(int flags)
Dumps a list of loaded class to the log file.
static void resetAllocCount(int kinds)
static void resetInstructionCount()
static int setAllocationLimit(int limit)
Establishes an object allocation limit in the current thread.
static int setGlobalAllocationLimit(int limit)
Establishes an object allocation limit for the entire VM.
static void startAllocCounting()
Count the number and aggregate size of memory allocations between two points.
static void startEmulatorTracing()
Starts sending Dalvik method trace info to the emulator.
static void startInstructionCounting()
Count the number of instructions executed between two points.
static void startMethodTracing()
This method is deprecated. not used, not needed
static void startMethodTracing(String traceFileName, int bufferSize, int flags)
Start method tracing, specifying a file name as well as a default buffer size.
static void stopAllocCounting()
static void stopEmulatorTracing()
Stops sending Dalvik method trace info to the emulator.
static void stopInstructionCounting()
static void stopMethodTracing()
Stops method tracing.
static long threadCpuTimeNanos()
Get an indication of thread CPU usage.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DEFAULT_METHOD_TRACE_FILE_NAME

Since: API Level 1

This constant is deprecated.
only used in one place, which is unused and deprecated

Specifies the default method trace data file name.

Constant Value: "/sdcard/dmtrace.trace"

public static final int KIND_ALL_COUNTS

Since: API Level 1

Constant Value: -1 (0xffffffff)

public static final int KIND_GLOBAL_ALLOCATED_BYTES

Since: API Level 1

Constant Value: 2 (0x00000002)

public static final int KIND_GLOBAL_ALLOCATED_OBJECTS

Since: API Level 1

Constant Value: 1 (0x00000001)

public static final int KIND_GLOBAL_CLASS_INIT_COUNT

Since: API Level 8

Constant Value: 32 (0x00000020)

public static final int KIND_GLOBAL_CLASS_INIT_TIME

Since: API Level 8

Constant Value: 64 (0x00000040)

public static final int KIND_GLOBAL_EXT_ALLOCATED_BYTES

Since: API Level 1

Constant Value: 8192 (0x00002000)

public static final int KIND_GLOBAL_EXT_ALLOCATED_OBJECTS

Since: API Level 1

Constant Value: 4096 (0x00001000)

public static final int KIND_GLOBAL_EXT_FREED_BYTES

Since: API Level 1

Constant Value: 32768 (0x00008000)

public static final int KIND_GLOBAL_EXT_FREED_OBJECTS

Since: API Level 1

Constant Value: 16384 (0x00004000)

public static final int KIND_GLOBAL_FREED_BYTES

Since: API Level 1

Constant Value: 8 (0x00000008)

public static final int KIND_GLOBAL_FREED_OBJECTS

Since: API Level 1

Constant Value: 4 (0x00000004)

public static final int KIND_GLOBAL_GC_INVOCATIONS

Since: API Level 1

Constant Value: 16 (0x00000010)

public static final int KIND_THREAD_ALLOCATED_BYTES

Since: API Level 1

Constant Value: 131072 (0x00020000)

public static final int KIND_THREAD_ALLOCATED_OBJECTS

Since: API Level 1

Constant Value: 65536 (0x00010000)

public static final int KIND_THREAD_CLASS_INIT_COUNT

Since: API Level 8

Constant Value: 2097152 (0x00200000)

public static final int KIND_THREAD_CLASS_INIT_TIME

Since: API Level 8

Constant Value: 4194304 (0x00400000)

public static final int KIND_THREAD_EXT_ALLOCATED_BYTES

Since: API Level 1

Constant Value: 536870912 (0x20000000)

public static final int KIND_THREAD_EXT_ALLOCATED_OBJECTS

Since: API Level 1

Constant Value: 268435456 (0x10000000)

public static final int KIND_THREAD_EXT_FREED_BYTES

Since: API Level 1

Constant Value: -2147483648 (0x80000000)

public static final int KIND_THREAD_EXT_FREED_OBJECTS

Since: API Level 1

Constant Value: 1073741824 (0x40000000)

public static final int KIND_THREAD_FREED_BYTES

Since: API Level 1

Constant Value: 524288 (0x00080000)

public static final int KIND_THREAD_FREED_OBJECTS

Since: API Level 1

Constant Value: 262144 (0x00040000)

public static final int KIND_THREAD_GC_INVOCATIONS

Since: API Level 1

Constant Value: 1048576 (0x00100000)

public static final int TRACE_COUNT_ALLOCS

Since: API Level 1

flag for startMethodTracing(), which adds the results from startAllocCounting to the trace key file.

Constant Value: 1 (0x00000001)

Public Methods

public static void dumpHprofData (String fileName)

Since: API Level 3

Dump "hprof" data to the specified file. This will cause a GC. The VM may create a temporary file in the same directory.

Parameters
fileName Full pathname of output file (e.g. "/sdcard/dump.hprof").
Throws
UnsupportedOperationException if the VM was built without HPROF support.
IOException if an error occurs while opening or writing files.

public static int getAllocCount (int kind)

Since: API Level 1

public static void getInstructionCount (int[] counts)

Since: API Level 1

public static int getLoadedClassCount ()

Since: API Level 1

Gets the number of loaded classes.

Returns
  • the number of loaded classes

public static boolean isDebuggerConnected ()

Since: API Level 1

Determines if a debugger is currently attached.

Returns
  • true if (and only if) a debugger is connected

public static boolean isDebuggingEnabled ()

Since: API Level 3

Determines if debugging is enabled in this VM. If debugging is not enabled, a debugger cannot be attached.

Returns
  • true if debugging is enabled

public static long lastDebuggerActivity ()

Since: API Level 1

Returns the time since the last known debugger activity.

Returns
  • the time in milliseconds, or -1 if the debugger is not connected

public static void printLoadedClasses (int flags)

Since: API Level 1

Dumps a list of loaded class to the log file.

public static void resetAllocCount (int kinds)

Since: API Level 1

public static void resetInstructionCount ()

Since: API Level 1

public static int setAllocationLimit (int limit)

Since: API Level 1

Establishes an object allocation limit in the current thread. Useful for catching regressions in code that is expected to operate without causing any allocations. The limit is valid from the return of this method until it is either changed or the thread terminates.

Parameters
limit the new limit. A value of 0 means not a single new object may be allocated. A value of -1 disables the limit.
Returns
  • the previous limit, or -1 if no limit was set

public static int setGlobalAllocationLimit (int limit)

Since: API Level 1

Establishes an object allocation limit for the entire VM. Useful for catching regressions in code that is expected to operate without causing any allocations. The limit is valid from the return of this method until it is either changed or the thread terminates.

Parameters
limit the new limit. A value of 0 means not a single new object may be allocated. A value of -1 disables the limit.
Returns
  • the previous limit, or -1 if no limit was set

public static void startAllocCounting ()

Since: API Level 1

Count the number and aggregate size of memory allocations between two points.

public static void startEmulatorTracing ()

Since: API Level 1

Starts sending Dalvik method trace info to the emulator.

public static void startInstructionCounting ()

Since: API Level 1

Count the number of instructions executed between two points.

public static void startMethodTracing ()

Since: API Level 1

This method is deprecated.
not used, not needed

Start method tracing with default name, size, and with 0 flags.

public static void startMethodTracing (String traceFileName, int bufferSize, int flags)

Since: API Level 1

Start method tracing, specifying a file name as well as a default buffer size. See Running the Traceview Debugging Program for information about reading trace files.

You can use either a fully qualified path and name, or just a name. If only a name is specified, the file will be created under the /sdcard/ directory. If a name is not given, the default is /sdcard/dmtrace.trace.

Parameters
traceFileName name to give the trace file
bufferSize the maximum size of both files combined. If passed as 0, it defaults to 8MB.
flags flags to control method tracing. The only one that is currently defined is TRACE_COUNT_ALLOCS.

public static void stopAllocCounting ()

Since: API Level 1

public static void stopEmulatorTracing ()

Since: API Level 1

Stops sending Dalvik method trace info to the emulator.

public static void stopInstructionCounting ()

Since: API Level 1

public static void stopMethodTracing ()

Since: API Level 1

Stops method tracing.

public static long threadCpuTimeNanos ()

Since: API Level 1

Get an indication of thread CPU usage. The value returned indicates the amount of time that the current thread has spent executing code or waiting for certain types of I/O.

The time is expressed in nanoseconds, and is only meaningful when compared to the result from an earlier call. Note that nanosecond resolution does not imply nanosecond accuracy.

Returns
  • the CPU usage. A value of -1 means the system does not support this feature.