Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/os/Debug#nestedclasses) \| [Constants](https://developer.android.com/reference/android/os/Debug#constants) \| [Methods](https://developer.android.com/reference/android/os/Debug#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/Debug#inhmethods)

# Debug

*** ** * ** ***


`
public

final

class
Debug
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.Debug |

<br />

*** ** * ** ***

Provides various debugging methods for Android applications, including
tracing and allocation counts.

**Logging Trace Files**

Debug can create log files that give details about an application, such as
a call stack and start/stop times for any running methods. See [Inspect Trace Logs with
Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files. To start logging
trace files, call one of the startMethodTracing() methods. To stop tracing,
call `https://developer.android.com/reference/android/os/Debug#stopMethodTracing()`.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/os/Debug.InstructionCount` *This class was deprecated in API level 23. Instruction counting is no longer supported.* |
| ` class` | `https://developer.android.com/reference/android/os/Debug.MemoryInfo` This class is used to retrieved various statistics about the memory mappings for this process. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/os/Debug#SHOW_CLASSLOADER` |
| `int` | `https://developer.android.com/reference/android/os/Debug#SHOW_FULL_DETAIL` Flags for printLoadedClasses(). |
| `int` | `https://developer.android.com/reference/android/os/Debug#SHOW_INITIALIZED` |
| `int` | `https://developer.android.com/reference/android/os/Debug#TRACE_COUNT_ALLOCS` *This constant was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |

| ### Public methods ||
|---|---|
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#attachJvmtiAgent(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String library, https://developer.android.com/reference/java/lang/String options, https://developer.android.com/reference/java/lang/ClassLoader classLoader) ` Attach a library as a jvmti agent to the current runtime, with the given classloader determining the library search path. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#changeDebugPort(int)(int port) ` *This method was deprecated in API level 15. no longer needed or useful* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#dumpHprofData(java.lang.String)(https://developer.android.com/reference/java/lang/String fileName) ` Dump "hprof" data to the specified file. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Debug#dumpService(java.lang.String,%20java.io.FileDescriptor,%20java.lang.String[])(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/io/FileDescriptor fd, https://developer.android.com/reference/java/lang/String args) ` Get a debugging dump of a system service by name. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#enableEmulatorTraceOutput()() ` *This method was deprecated in API level 34. Please use other tracing method in this class.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getBinderDeathObjectCount()() ` Returns the number of death notification links to Binder objects that exist in the current process. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getBinderLocalObjectCount()() ` Returns the number of active local Binder objects that exist in the current process. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getBinderProxyObjectCount()() ` Returns the number of references to remote proxy Binder objects that exist in the current process. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getBinderReceivedTransactions()() ` Returns the number of received transactions from the binder driver. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getBinderSentTransactions()() ` Returns the number of sent transactions from this process. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalAllocCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalAllocSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalClassInitCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalClassInitTime()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalExternalAllocCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalExternalAllocSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalExternalFreedCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalExternalFreedSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalFreedCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalFreedSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getGlobalGcInvocationCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getInstanceCount(java.lang.Class)(https://developer.android.com/reference/java/lang/Class<T> cls) ` Counts the number of instances of the specified class. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getInstanceCount(java.lang.Class,%20boolean)(https://developer.android.com/reference/java/lang/Class<T> cls, boolean includeAssignable) ` Counts the number of instances of the specified class. |
| ` static long[]` | ` https://developer.android.com/reference/android/os/Debug#getInstanceCounts(java.util.List<java.lang.Class>,%20boolean)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<T>> classes, boolean includeAssignable) ` Counts the number of instances of the specified classes. |
| ` static long[]` | ` https://developer.android.com/reference/android/os/Debug#getInstanceCounts(java.util.List<java.lang.Class>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<T>> classes) ` Counts the number of instances of the specified classes. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getLoadedClassCount()() ` Get the number of loaded classes. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#getMemoryInfo(android.os.Debug.MemoryInfo)(https://developer.android.com/reference/android/os/Debug.MemoryInfo memoryInfo) ` Retrieves information about this processes memory usages. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getNativeHeapAllocatedSize()() ` Returns the amount of allocated memory in the native heap. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getNativeHeapFreeSize()() ` Returns the amount of free memory in the native heap. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getNativeHeapSize()() ` Returns the size of the native heap. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getPss()() ` Retrieves the PSS memory used by the process as given by the smaps. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#getRss()() ` Retrieves the RSS memory used by the process as given by the status file. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/os/Debug#getRuntimeStat(java.lang.String)(https://developer.android.com/reference/java/lang/String statName) ` Returns the value of a particular runtime statistic or `null` if no such runtime statistic exists. |
| ` static https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/os/Debug#getRuntimeStats()() ` Returns a map of the names/values of the runtime statistics that `https://developer.android.com/reference/android/os/Debug#getRuntimeStat(java.lang.String)` supports. |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getThreadAllocCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getThreadAllocSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getThreadExternalAllocCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getThreadExternalAllocSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#getThreadGcInvocationCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Debug#isDebuggerConnected()() ` Determine if a debugger is currently attached. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#printLoadedClasses(int)(int flags) ` Dump a list of all currently loaded class to the log file. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetAllCounts()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalAllocCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalAllocSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalClassInitCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalClassInitTime()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalExternalAllocCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalExternalAllocSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalExternalFreedCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalExternalFreedSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalFreedCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalFreedSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetGlobalGcInvocationCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetThreadAllocCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetThreadAllocSize()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetThreadExternalAllocCount()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetThreadExternalAllocSize()() ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#resetThreadGcInvocationCount()() ` *This method was deprecated in API level 23. Accurate counting is a burden on the runtime and may be removed.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#setAllocationLimit(int)(int limit) ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static int` | ` https://developer.android.com/reference/android/os/Debug#setGlobalAllocationLimit(int)(int limit) ` *This method was deprecated in API level 15. This method is now obsolete.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startAllocCounting()() ` *This method was deprecated in API level 18. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startMethodTracing()() ` Start method tracing with default log name and buffer size. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startMethodTracing(java.lang.String,%20int,%20int)(https://developer.android.com/reference/java/lang/String tracePath, int bufferSize, int flags) ` Start method tracing, specifying the trace log file name, the buffer size, and flags. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startMethodTracing(java.lang.String)(https://developer.android.com/reference/java/lang/String tracePath) ` Start method tracing, specifying the trace log file path. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startMethodTracing(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String tracePath, int bufferSize) ` Start method tracing, specifying the trace log file name and the buffer size. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startMethodTracingSampling(java.lang.String,%20int,%20int)(https://developer.android.com/reference/java/lang/String tracePath, int bufferSize, int intervalUs) ` Start sampling-based method tracing, specifying the trace log file name, the buffer size, and the sampling interval. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#startNativeTracing()() ` Enable qemu tracing. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#stopAllocCounting()() ` *This method was deprecated in API level 18. Accurate counting is a burden on the runtime and may be removed.* |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#stopMethodTracing()() ` Stop method tracing. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#stopNativeTracing()() ` Stop qemu tracing. |
| ` static long` | ` https://developer.android.com/reference/android/os/Debug#threadCpuTimeNanos()() ` Get an indication of thread CPU usage. |
| ` static void` | ` https://developer.android.com/reference/android/os/Debug#waitForDebugger()() ` Wait until a debugger attaches. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Debug#waitingForDebugger()() ` Returns "true" if one or more threads is waiting for a debugger to attach. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### SHOW_CLASSLOADER

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SHOW_CLASSLOADER
```

<br />

<br />

Constant Value:

2
(0x00000002)


### SHOW_FULL_DETAIL

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SHOW_FULL_DETAIL
```

Flags for printLoadedClasses(). Default behavior is to only show
the class name.

<br />

Constant Value:

1
(0x00000001)


### SHOW_INITIALIZED

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SHOW_INITIALIZED
```

<br />

<br />

Constant Value:

4
(0x00000004)


### TRACE_COUNT_ALLOCS

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TRACE_COUNT_ALLOCS
```


**This constant was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Flags for startMethodTracing(). These can be ORed together.

TRACE_COUNT_ALLOCS adds the results from startAllocCounting to the
trace key file.

<br />

Constant Value:

1
(0x00000001)


## Public methods

### attachJvmtiAgent

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void attachJvmtiAgent (String library, 
                String options, 
                ClassLoader classLoader)
```

Attach a library as a jvmti agent to the current runtime, with the given classloader
determining the library search path.


Note: agents may only be attached to debuggable apps. Otherwise, this function will
throw a SecurityException.

<br />

| Parameters ||
|---|---|
| `library` | `String`: the library containing the agent. This value cannot be `null`. <br /> |
| `options` | `String`: the options passed to the agent. This value may be `null`. <br /> |
| `classLoader` | `ClassLoader`: the classloader determining the library search path. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if the agent could not be attached. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if the app is not debuggable. |

### changeDebugPort

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void changeDebugPort (int port)
```


**This method was deprecated
in API level 15.**   

no longer needed or useful

Change the JDWP port.

<br />

| Parameters ||
|---|---|
| `port` | `int` <br /> |

### dumpHprofData

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpHprofData (String fileName)
```

Dump "hprof" data to the specified file. This may cause a GC.

<br />

| Parameters ||
|---|---|
| `fileName` | `String`: Full pathname of output file (e.g. "/sdcard/dump.hprof"). <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an error occurs while opening or writing files. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if the VM was built without HPROF support. |

### dumpService

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean dumpService (String name, 
                FileDescriptor fd, 
                String[] args)
```

Get a debugging dump of a system service by name.

Most services require the caller to hold android.permission.DUMP.

<br />

| Parameters ||
|---|---|
| `name` | `String`: of the service to dump <br /> |
| `fd` | `FileDescriptor`: to write dump output to (usually an output log file) <br /> |
| `args` | `String`: to pass to the service's dump method, may be null <br /> |

| Returns ||
|---|---|
| `boolean` | true if the service was dumped successfully, false if the service could not be found or had an error while dumping <br /> |

### enableEmulatorTraceOutput

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void enableEmulatorTraceOutput ()
```


**This method was deprecated
in API level 34.**   

Please use other tracing method in this class.

Enable "emulator traces", in which information about the current
method is made available to the "emulator -trace" feature. There
is no corresponding "disable" call -- this is intended for use by
the framework when tracing should be turned on and left that way, so
that traces captured with F9/F10 will include the necessary data.

This puts the VM into "profile" mode, which has performance
consequences.

To temporarily enable tracing, use `https://developer.android.com/reference/android/os/Debug#startNativeTracing()`.

<br />

### getBinderDeathObjectCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getBinderDeathObjectCount ()
```

Returns the number of death notification links to Binder objects that
exist in the current process.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getBinderLocalObjectCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getBinderLocalObjectCount ()
```

Returns the number of active local Binder objects that exist in the
current process.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getBinderProxyObjectCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getBinderProxyObjectCount ()
```

Returns the number of references to remote proxy Binder objects that
exist in the current process.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getBinderReceivedTransactions

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getBinderReceivedTransactions ()
```

Returns the number of received transactions from the binder driver.

<br />

| Returns ||
|---|---|
| `int` | The number of received transactions or -1 if it could not read the stats. <br /> |

### getBinderSentTransactions

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getBinderSentTransactions ()
```

Returns the number of sent transactions from this process.

<br />

| Returns ||
|---|---|
| `int` | The number of sent transactions or -1 if it could not read t. <br /> |

### getGlobalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalAllocCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the global count of objects allocated by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalAllocSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the global size, in bytes, of objects allocated by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalClassInitCount

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalClassInitCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the number of classes successfully initialized (ie those that executed without
throwing an exception) between a `https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and
`https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalClassInitTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalClassInitTime ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the time spent successfully initializing classes between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalExternalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalExternalAllocCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and always returns 0.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalExternalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalExternalAllocSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and always returns 0.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalExternalFreedCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalExternalFreedCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and always returns 0.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalExternalFreedSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalExternalFreedSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalFreedCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalFreedCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the global count of objects freed by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalFreedSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalFreedSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the global size, in bytes, of objects freed by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGlobalGcInvocationCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getGlobalGcInvocationCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the number of non-concurrent GC invocations between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getInstanceCount

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static long getInstanceCount (Class<T> cls)
```

Counts the number of instances of the specified class.

**Warning:** This operation can be expensive, as it may involve traversing portions
of the Java heap. It is primarily intended for debugging purposes and should not be used in
performance-critical code.

It's intended to help developers identify object leaks or to validate
the number of instances of a specific class during development.

It is the caller's responsibility to do GC if they don't want unreachable
objects to get counted.

<br />

| Parameters ||
|---|---|
| `cls` | `Class`: `https://developer.android.com/reference/java/lang/Class` the class to count instances of. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `long` | the number of matching instances. <br /> |

### getInstanceCount

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static long getInstanceCount (Class<T> cls, 
                boolean includeAssignable)
```

Counts the number of instances of the specified class.

**Warning:** This operation can be expensive, as it may involve traversing portions
of the Java heap. It is primarily intended for debugging purposes and should not be used in
performance-critical code.

It's intended to help developers identify object leaks or to validate
the number of instances of a specific class during development.

It is the caller's responsibility to do GC if they don't want unreachable
objects to get counted.

<br />

| Parameters ||
|---|---|
| `cls` | `Class`: `https://developer.android.com/reference/java/lang/Class` the class to count instances of. This value cannot be `null`. <br /> |
| `includeAssignable` | `boolean`: if true, any instance whose class is assignable to `cls`, as defined by `https://developer.android.com/reference/java/lang/Class#isAssignableFrom(java.lang.Class<?>)`, is counted. If false, only instances whose class is equal to `cls` are counted. <br /> |

| Returns ||
|---|---|
| `long` | the number of matching instances. <br /> |

### getInstanceCounts

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static long[] getInstanceCounts (List<Class<T>> classes, 
                boolean includeAssignable)
```

Counts the number of instances of the specified classes.

**Warning:** This operation can be expensive, as it may involve traversing portions
of the Java heap. It is primarily intended for debugging purposes and should not be used in
performance-critical code.

It's intended to help developers identify object leaks or to validate
the number of instances of a specific class during development.

It is the caller's responsibility to do GC if they don't want unreachable
objects to get counted.

<br />

| Parameters ||
|---|---|
| `classes` | `List`: An array of `https://developer.android.com/reference/java/lang/Class` objects representing the classes to count instances of. Must not be null. <br /> |
| `includeAssignable` | `boolean`: if true, any instance whose class is assignable to `cls`, as defined by `https://developer.android.com/reference/java/lang/Class#isAssignableFrom(java.lang.Class<?>)`, is counted. If false, only instances whose class is equal to `cls` are counted. <br /> |

| Returns ||
|---|---|
| `long[]` | An array of `long` values, where each element corresponds to the number of instances of the class at the same index in the `classes` list. The returned array will have the same length as the input `classes` array. If the system is under memory pressure and unable to allocate the return array a empty array will be returned. This value cannot be `null`. <br /> |

### getInstanceCounts

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static long[] getInstanceCounts (List<Class<T>> classes)
```

Counts the number of instances of the specified classes.

**Warning:** This operation can be expensive, as it may involve traversing portions
of the Java heap. It is primarily intended for debugging purposes and should not be used in
performance-critical code.

It's intended to help developers identify object leaks or to validate
the number of instances of a specific class during development.

It is the caller's responsibility to do GC if they don't want unreachable
objects to get counted.

<br />

| Parameters ||
|---|---|
| `classes` | `List`: An array of `https://developer.android.com/reference/java/lang/Class` objects representing the classes to count instances of. Must not be null. <br /> |

| Returns ||
|---|---|
| `long[]` | An array of `long` values, where each element corresponds to the number of instances of the class at the same index in the `classes` list. The returned array will have the same length as the input `classes` array. If the system is under memory pressure and unable to allocate the return array a empty array will be returned. This value cannot be `null`. <br /> |

### getLoadedClassCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getLoadedClassCount ()
```

Get the number of loaded classes.

<br />

| Returns ||
|---|---|
| `int` | the number of loaded classes. <br /> |

### getMemoryInfo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void getMemoryInfo (Debug.MemoryInfo memoryInfo)
```

Retrieves information about this processes memory usages. This information is broken down by
how much is in use by dalvik, the native heap, and everything else.

**Note:** this method directly retrieves memory information for the given process
from low-level data available to it. It may not be able to retrieve information about
some protected allocations, such as graphics. If you want to be sure you can see
all information about allocations by the process, use
`https://developer.android.com/reference/android/app/ActivityManager#getProcessMemoryInfo(int[])` instead.

<br />

<br />

| Parameters ||
|---|---|
| `memoryInfo` | `Debug.MemoryInfo` <br /> |

### getNativeHeapAllocatedSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long getNativeHeapAllocatedSize ()
```

Returns the amount of allocated memory in the native heap.

<br />

| Returns ||
|---|---|
| `long` | The allocated size in bytes. <br /> |

### getNativeHeapFreeSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long getNativeHeapFreeSize ()
```

Returns the amount of free memory in the native heap.

<br />

| Returns ||
|---|---|
| `long` | The freed size in bytes. <br /> |

### getNativeHeapSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long getNativeHeapSize ()
```

Returns the size of the native heap.

<br />

| Returns ||
|---|---|
| `long` | The size of the native heap in bytes. <br /> |

### getPss

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long getPss ()
```

Retrieves the PSS memory used by the process as given by the
smaps.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getRss

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long getRss ()
```

Retrieves the RSS memory used by the process as given by the status file.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getRuntimeStat

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getRuntimeStat (String statName)
```

Returns the value of a particular runtime statistic or `null` if no
such runtime statistic exists.

The following table lists the runtime statistics that the runtime supports.
All statistics are approximate. Individual allocations may not be immediately reflected
in the results.
Note runtime statistics may be added or removed in a future API level.

| Runtime statistic name | Meaning | Example | Supported (API Levels) |
|---|---|---|---|
| art.gc.gc-count | The number of garbage collection runs. | `164` | 23 |
| art.gc.gc-time | The total duration of garbage collection runs in ms. | `62364` | 23 |
| art.gc.bytes-allocated | The total number of bytes that the application allocated. | `1463948408` | 23 |
| art.gc.bytes-freed | The total number of bytes that garbage collection reclaimed. | `1313493084` | 23 |
| art.gc.blocking-gc-count | The number of blocking garbage collection runs. | `2` | 23 |
| art.gc.blocking-gc-time | The total duration of blocking garbage collection runs in ms. | `804` | 23 |
| art.gc.gc-count-rate-histogram | Every 10 seconds, the gc-count-rate is computed as the number of garbage collection runs that have occurred over the last 10 seconds. art.gc.gc-count-rate-histogram is a histogram of the gc-count-rate samples taken since the process began. The histogram can be used to identify instances of high rates of garbage collection runs. For example, a histogram of "0:34503,1:45350,2:11281,3:8088,4:43,5:8" shows that most of the time there are between 0 and 2 garbage collection runs every 10 seconds, but there were 8 distinct 10-second intervals in which 5 garbage collection runs occurred. | `0:34503,1:45350,2:11281,3:8088,4:43,5:8` | 23 |
| art.gc.blocking-gc-count-rate-histogram | Every 10 seconds, the blocking-gc-count-rate is computed as the number of blocking garbage collection runs that have occurred over the last 10 seconds. art.gc.blocking-gc-count-rate-histogram is a histogram of the blocking-gc-count-rate samples taken since the process began. The histogram can be used to identify instances of high rates of blocking garbage collection runs. For example, a histogram of "0:99269,1:1,2:1" shows that most of the time there are zero blocking garbage collection runs every 10 seconds, but there was one 10-second interval in which one blocking garbage collection run occurred, and there was one interval in which two blocking garbage collection runs occurred. | `0:99269,1:1,2:1` | 23 |

<br />

<br />

| Parameters ||
|---|---|
| `statName` | `String`: the name of the runtime statistic to look up. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the value of the specified runtime statistic or `null` if the runtime statistic doesn't exist. <br /> |

### getRuntimeStats

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Map<String, String> getRuntimeStats ()
```

Returns a map of the names/values of the runtime statistics
that `https://developer.android.com/reference/android/os/Debug#getRuntimeStat(java.lang.String)` supports.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | a map of the names/values of the supported runtime statistics. <br /> |

### getThreadAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getThreadAllocCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the thread-local count of objects allocated by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getThreadAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getThreadAllocSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the thread-local size of objects allocated by the runtime between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | The allocated size in bytes. <br /> |

### getThreadExternalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getThreadExternalAllocCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getThreadExternalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getThreadExternalAllocSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getThreadGcInvocationCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getThreadGcInvocationCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Returns the number of thread-local non-concurrent GC invocations between a
`https://developer.android.com/reference/android/os/Debug#startAllocCounting()` and `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### isDebuggerConnected

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isDebuggerConnected ()
```

Determine if a debugger is currently attached.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### printLoadedClasses

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void printLoadedClasses (int flags)
```

Dump a list of all currently loaded class to the log file.

<br />

| Parameters ||
|---|---|
| `flags` | `int`: See constants above. <br /> |

### resetAllCounts

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetAllCounts ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears all the global and thread-local memory allocation counters.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#startAllocCounting()`

### resetGlobalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalAllocCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the global count of objects allocated.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalAllocCount()`

### resetGlobalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalAllocSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the global size of objects allocated.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalAllocSize()`

### resetGlobalClassInitCount

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalClassInitCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the count of classes initialized.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalClassInitCount()`

### resetGlobalClassInitTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalClassInitTime ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the count of time spent initializing classes.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalClassInitTime()`

### resetGlobalExternalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalExternalAllocCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetGlobalExternalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalExternalAllocSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetGlobalExternalFreedCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalExternalFreedCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetGlobalExternalFreedSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalExternalFreedSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetGlobalFreedCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalFreedCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the global count of objects freed.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalFreedCount()`

### resetGlobalFreedSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalFreedSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the global size of objects freed.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalFreedSize()`

### resetGlobalGcInvocationCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetGlobalGcInvocationCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the count of non-concurrent GC invocations.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getGlobalGcInvocationCount()`

### resetThreadAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetThreadAllocCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the thread-local count of objects allocated.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getThreadAllocCount()`

### resetThreadAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetThreadAllocSize ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the thread-local count of objects allocated.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getThreadAllocSize()`

### resetThreadExternalAllocCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetThreadExternalAllocCount ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetThreadExternalAllocSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetThreadExternalAllocSize ()
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

This method exists for compatibility and has no effect.

<br />

### resetThreadGcInvocationCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void resetThreadGcInvocationCount ()
```


**This method was deprecated
in API level 23.**   

Accurate counting is a burden on the runtime and may be removed.

Clears the thread-local count of non-concurrent GC invocations.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Debug#getThreadGcInvocationCount()`

### setAllocationLimit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int setAllocationLimit (int limit)
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

Establish an object allocation limit in the current thread.
This feature was never enabled in release builds. The
allocation limits feature was removed in Honeycomb. This
method exists for compatibility and always returns -1 and has
no effect.

<br />

| Parameters ||
|---|---|
| `limit` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### setGlobalAllocationLimit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int setGlobalAllocationLimit (int limit)
```


**This method was deprecated
in API level 15.**   

This method is now obsolete.

Establish a global object allocation limit. This feature was
never enabled in release builds. The allocation limits feature
was removed in Honeycomb. This method exists for compatibility
and always returns -1 and has no effect.

<br />

| Parameters ||
|---|---|
| `limit` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### startAllocCounting

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startAllocCounting ()
```


**This method was deprecated
in API level 18.**   

Accurate counting is a burden on the runtime and may be removed.

Start counting the number and aggregate size of memory allocations.

The `https://developer.android.com/reference/android/os/Debug#startAllocCounting()` method resets the counts and enables counting.
The `https://developer.android.com/reference/android/os/Debug#stopAllocCounting()` method disables the counting so that the analysis
code doesn't cause additional allocations. The various `get` methods return
the specified value. And the various `reset` methods reset the specified
count.

Counts are kept for the system as a whole (global) and for each thread.
The per-thread counts for threads other than the current thread
are not cleared by the "reset" or "start" calls.

<br />

<br />

### startMethodTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startMethodTracing ()
```

Start method tracing with default log name and buffer size.


By default, the trace file is called "dmtrace.trace" and it's placed
under your package-specific directory on primary shared/external storage,
as returned by `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.


See [Inspect Trace Logs
with Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files.


When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
`https://developer.android.com/reference/android/os/Debug#startMethodTracingSampling(java.lang.String,%20int,%20int)` or "native" tracing
in the emulator via `https://developer.android.com/reference/android/os/Debug#startNativeTracing()`.

<br />

<br />

### startMethodTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startMethodTracing (String tracePath, 
                int bufferSize, 
                int flags)
```

Start method tracing, specifying the trace log file name, the buffer
size, and flags.


When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.


See [Inspect Trace Logs
with Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files.


When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
`https://developer.android.com/reference/android/os/Debug#startMethodTracingSampling(java.lang.String,%20int,%20int)` or "native" tracing
in the emulator via `https://developer.android.com/reference/android/os/Debug#startNativeTracing()`.

<br />

<br />

| Parameters ||
|---|---|
| `tracePath` | `String`: Path to the trace log file to create. If `null`, this will default to "dmtrace.trace". If the file already exists, it will be truncated. If the path given does not end in ".trace", it will be appended for you. <br /> |
| `bufferSize` | `int`: The maximum amount of trace data we gather. If not given, it defaults to 8MB. <br /> |
| `flags` | `int`: Flags to control method tracing. The following flags are supported: 0x0001 `https://developer.android.com/reference/android/os/Debug#TRACE_COUNT_ALLOCS` Flags to control time source: These are available with API #34 and higher. 0x0010 Report the elapsed time since the start of the trace. 0x0100 Report the time the thread has spent on the CPU since the start of the trace. Please note that the thread cpu incurs a significant (typically 2-3x) performance penalty. Use this flag only when necessary. If neither of these flags are set, both the elapsed time and the thread cpu time are reported. <br /> |

### startMethodTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startMethodTracing (String tracePath)
```

Start method tracing, specifying the trace log file path.


When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.


See [Inspect Trace Logs
with Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files.


When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
`https://developer.android.com/reference/android/os/Debug#startMethodTracingSampling(java.lang.String,%20int,%20int)` or "native" tracing
in the emulator via `https://developer.android.com/reference/android/os/Debug#startNativeTracing()`.

<br />

<br />

| Parameters ||
|---|---|
| `tracePath` | `String`: Path to the trace log file to create. If `null`, this will default to "dmtrace.trace". If the file already exists, it will be truncated. If the path given does not end in ".trace", it will be appended for you. <br /> |

### startMethodTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startMethodTracing (String tracePath, 
                int bufferSize)
```

Start method tracing, specifying the trace log file name and the buffer
size.


When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.


See [Inspect Trace Logs
with Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files.


When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
`https://developer.android.com/reference/android/os/Debug#startMethodTracingSampling(java.lang.String,%20int,%20int)` or "native" tracing
in the emulator via `https://developer.android.com/reference/android/os/Debug#startNativeTracing()`.

<br />

<br />

| Parameters ||
|---|---|
| `tracePath` | `String`: Path to the trace log file to create. If `null`, this will default to "dmtrace.trace". If the file already exists, it will be truncated. If the path given does not end in ".trace", it will be appended for you. <br /> |
| `bufferSize` | `int`: The maximum amount of trace data we gather. If not given, it defaults to 8MB. <br /> |

### startMethodTracingSampling

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startMethodTracingSampling (String tracePath, 
                int bufferSize, 
                int intervalUs)
```

Start sampling-based method tracing, specifying the trace log file name,
the buffer size, and the sampling interval.


When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.


See [Inspect Trace Logs
with Traceview](https://developer.android.com/studio/profile/traceview) for information about reading trace files.

<br />

| Parameters ||
|---|---|
| `tracePath` | `String`: Path to the trace log file to create. If `null`, this will default to "dmtrace.trace". If the file already exists, it will be truncated. If the path given does not end in ".trace", it will be appended for you. <br /> |
| `bufferSize` | `int`: The maximum amount of trace data we gather. If not given, it defaults to 8MB. <br /> |
| `intervalUs` | `int`: The amount of time between each sample in microseconds. <br /> |

### startNativeTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void startNativeTracing ()
```

Enable qemu tracing. For this to work requires running everything inside
the qemu emulator; otherwise, this method will have no effect. The trace
file is specified on the command line when the emulator is started. For
example, the following command line   

`emulator -trace foo`  

will start running the emulator and create a trace file named "foo". This
method simply enables writing the trace records to the trace file.


The main differences between this and `https://developer.android.com/reference/android/os/Debug#startMethodTracing()` are
that tracing in the qemu emulator traces every cpu instruction of every
process, including kernel code, so we have more complete information,
including all context switches. We can also get more detailed information
such as cache misses. The sequence of calls is determined by
post-processing the instruction trace. The qemu tracing is also done
without modifying the application or perturbing the timing of calls
because no instrumentation is added to the application being traced.


One limitation of using this method compared to using
`https://developer.android.com/reference/android/os/Debug#startMethodTracing()` on the real device is that the emulator
does not model all of the real hardware effects such as memory and
bus contention. The emulator also has a simple cache model and cannot
capture all the complexities of a real cache.

<br />

<br />

### stopAllocCounting

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void stopAllocCounting ()
```


**This method was deprecated
in API level 18.**   

Accurate counting is a burden on the runtime and may be removed.

Stop counting the number and aggregate size of memory allocations.

<br />

### stopMethodTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void stopMethodTracing ()
```

Stop method tracing.

<br />

### stopNativeTracing

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void stopNativeTracing ()
```

Stop qemu tracing. See `https://developer.android.com/reference/android/os/Debug#startNativeTracing()` to start tracing.

Tracing can be started and stopped as many times as desired. When
the qemu emulator itself is stopped then the buffered trace records
are flushed and written to the trace file. In fact, it is not necessary
to call this method at all; simply killing qemu is sufficient. But
starting and stopping a trace is useful for examining a specific
region of code.

<br />

<br />

### threadCpuTimeNanos

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long threadCpuTimeNanos ()
```

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.

On system which don't support this operation, the call returns -1.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### waitForDebugger

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void waitForDebugger ()
```

Wait until a debugger attaches. As soon as the debugger attaches,
this returns, so you will need to place a breakpoint after the
waitForDebugger() call if you want to start tracing immediately.

<br />

### waitingForDebugger

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean waitingForDebugger ()
```

Returns "true" if one or more threads is waiting for a debugger
to attach.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |