Build 1.0_r1(from source)

dalvik.system
Class VMRuntime

java.lang.Object
  extended by dalvik.system.VMRuntime

public final class VMRuntime
extends Object

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.


Method Summary
 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.
 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.
 boolean trackExternalAllocation(long size)
          Asks the VM if <size> bytes can be allocated in an external heap.
 void trackExternalFree(long size)
          Tells the VM that <size> bytes have been freed in an external heap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRuntime

public static VMRuntime getRuntime()
Returns the object that represents the VM instance's Dalvik-specific runtime environment.

Returns:
the runtime object

getTargetHeapUtilization

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

setTargetHeapUtilization

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

getMinimumHeapSize

public long getMinimumHeapSize()
Returns the minimum heap size, or zero if no minimum is in effect.

Returns:
the minimum heap size value

setMinimumHeapSize

public 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

gcSoftReferences

public void gcSoftReferences()
Requests that the virtual machine collect available memory, and collects any SoftReferences that are not strongly-reachable.


runFinalizationSync

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.


trackExternalAllocation

public boolean trackExternalAllocation(long size)
Asks the VM if <size> bytes can be allocated in an external heap. This information may be used to limit the amount of memory available to Dalvik threads. Returns false if the VM would rather that the caller did not allocate that much memory. If the call returns false, the VM will not update its internal counts. May cause one or more GCs as a side-effect. Called by JNI code.

Parameters:
size - The number of bytes that have been allocated.
Returns:
true if the VM thinks there's enough process memory to satisfy this request, or false if not.

trackExternalFree

public void trackExternalFree(long size)
Tells the VM that <size> bytes have been freed in an external heap. This information may be used to control the amount of memory available to Dalvik threads. Called by JNI code.

Parameters:
size - The number of bytes that have been freed. This same number should have been passed to trackExternalAlloc() when the underlying memory was originally allocated.

getExternalBytesAllocated

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


Build 1.0_r1(from source)

Please submit a feedback, bug or feature