Android
dalvik.system
public final class

dalvik.system.VMRuntime

java.lang.Object
dalvik.system.VMRuntime

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.
Methods inherited from class java.lang.Object

Details

Public Methods

public void gcSoftReferences()

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

public long getExternalBytesAllocated()

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

public long getMinimumHeapSize()

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

Returns

  • the minimum heap size value

public static VMRuntime getRuntime()

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

Returns

  • the runtime object

public float getTargetHeapUtilization()

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()

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)

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.

Parameters

size the new suggested minimum heap size, in bytes

Returns

  • the old minimum heap size value

public float setTargetHeapUtilization(float newTarget)

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.

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
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48