public final class

VMRuntime

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

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 an interface to VM-global, Dalvik-specific features. An application cannot create its own Runtime instance, and must obtain one from the getRuntime method.

Summary

Public Methods
void gcSoftReferences()
Requests that the virtual machine collect available memory, and collects any SoftReferences that are not strongly-reachable.
long getExternalBytesAllocated()
Returns the number of externally-allocated bytes being tracked by trackExternalAllocation/Free().
long getMinimumHeapSize()
Returns the minimum heap size, or zero if no minimum is in effect.
static VMRuntime getRuntime()
Returns the object that represents the VM instance's Dalvik-specific runtime environment.
float getTargetHeapUtilization()
Gets the current ideal heap utilization, represented as a number between zero and one.
void runFinalizationSync()
Does not return until any pending finalizers have been called.
synchronized long setMinimumHeapSize(long size)
Sets the desired minimum heap size, and returns the old minimum size.
float setTargetHeapUtilization(float newTarget)
Sets the current ideal heap utilization, represented as a number between zero and one.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void gcSoftReferences ()

Since: API Level 1

Requests that the virtual machine collect available memory, and collects any SoftReferences that are not strongly-reachable.

public long getExternalBytesAllocated ()

Since: API Level 1

Returns the number of externally-allocated bytes being tracked by trackExternalAllocation/Free().

Returns
  • the number of bytes

public long getMinimumHeapSize ()

Since: API Level 1

Returns the minimum heap size, or zero if no minimum is in effect.

Returns
  • the minimum heap size value

public static VMRuntime getRuntime ()

Since: API Level 1

Returns the object that represents the VM instance's Dalvik-specific runtime environment.

Returns
  • the runtime object

public float getTargetHeapUtilization ()

Since: API Level 1

Gets the current ideal heap utilization, represented as a number between zero and one. After a GC happens, the Dalvik heap may be resized so that (size of live objects) / (size of heap) is equal to this number.

Returns
  • the current ideal heap utilization

public void runFinalizationSync ()

Since: API Level 1

Does not return until any pending finalizers have been called. This may or may not happen in the context of the calling thread. No exceptions will escape.

public synchronized long setMinimumHeapSize (long size)

Since: API Level 1

Sets the desired minimum heap size, and returns the old minimum size. If size is larger than the maximum size, the maximum size will be used. If size is zero or negative, the minimum size constraint will be removed.

Synchronized to make the order of the exchange reliable.

This is only a hint to the garbage collector and may be ignored.

Parameters
size the new suggested minimum heap size, in bytes
Returns
  • the old minimum heap size value

public float setTargetHeapUtilization (float newTarget)

Since: API Level 1

Sets the current ideal heap utilization, represented as a number between zero and one. After a GC happens, the Dalvik heap may be resized so that (size of live objects) / (size of heap) is equal to this number.

This is only a hint to the garbage collector and may be ignored.

Parameters
newTarget the new suggested ideal heap utilization. This value may be adjusted internally.
Returns
  • the previous ideal heap utilization
Throws
IllegalArgumentException if newTarget is <= 0.0 or >= 1.0