Debug.GetInstanceCounts Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| GetInstanceCounts(IList<Class>) |
Counts the number of instances of the specified classes. |
| GetInstanceCounts(IList<Class>, Boolean) |
Counts the number of instances of the specified classes. |
GetInstanceCounts(IList<Class>)
Counts the number of instances of the specified classes.
[Android.Runtime.Register("getInstanceCounts", "(Ljava/util/List;)[J", "", ApiSince=36)]
public static long[] GetInstanceCounts(System.Collections.Generic.IList<Java.Lang.Class> classes);
[<Android.Runtime.Register("getInstanceCounts", "(Ljava/util/List;)[J", "", ApiSince=36)>]
static member GetInstanceCounts : System.Collections.Generic.IList<Java.Lang.Class> -> int64[]
Parameters
An array of Class objects representing the classes to count instances
of. Must not be null.
Returns
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.
- Attributes
Remarks
Counts the number of instances of the specified classes.
<b>Warning:</b> 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.
Java documentation for android.os.Debug.getInstanceCounts(java.util.List<java.lang.Class>).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
GetInstanceCounts(IList<Class>, Boolean)
Counts the number of instances of the specified classes.
[Android.Runtime.Register("getInstanceCounts", "(Ljava/util/List;Z)[J", "", ApiSince=36)]
public static long[] GetInstanceCounts(System.Collections.Generic.IList<Java.Lang.Class> classes, bool includeAssignable);
[<Android.Runtime.Register("getInstanceCounts", "(Ljava/util/List;Z)[J", "", ApiSince=36)>]
static member GetInstanceCounts : System.Collections.Generic.IList<Java.Lang.Class> * bool -> int64[]
Parameters
An array of Class objects representing the classes to count instances
of. Must not be null.
- includeAssignable
- Boolean
if true, any instance whose class is assignable to
cls, as defined by Class#isAssignableFrom,
is counted. If false, only instances whose class is
equal to cls are counted.
Returns
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.
- Attributes
Remarks
Counts the number of instances of the specified classes.
<b>Warning:</b> 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.
Java documentation for android.os.Debug.getInstanceCounts(java.util.List<java.lang.Class>, boolean).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.