java.lang
Class Runtime

java.lang.Object
  |
  +--java.lang.Runtime

public class Runtime
extends Object

Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getRuntime method.

An application cannot create its own instance of this class.

Since:
JDK1.0
Version:
1.57, 04/06/00
Author:
unascribed
See Also:
getRuntime()

Method Summary
 long freeMemory()
          Returns the amount of free memory in the system.
static Runtime getRuntime()
          Returns the runtime object associated with the current Java application.
 long totalMemory()
          Returns the total amount of memory in the Java Virtual Machine.
 void traceInstructions(boolean on)
          Enables/Disables tracing of instructions.
 void traceMethodCalls(boolean on)
          Enables/Disables tracing of method calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Method Detail

freeMemory

public long freeMemory()
Returns the amount of free memory in the system. Calling the gc method may result in increasing the value returned by freeMemory.

Returns:
an approximation to the total amount of memory currently available for future allocated objects, measured in bytes.

getRuntime

public static Runtime getRuntime()
Returns the runtime object associated with the current Java application. Most of the methods of class Runtime are instance methods and must be invoked with respect to the current runtime object.

Returns:
the Runtime object associated with the current Java application.

totalMemory

public long totalMemory()
Returns the total amount of memory in the Java Virtual Machine. The value returned by this method may vary over time, depending on the host environment.

Note that the amount of memory required to hold an object of any given type may be implementation-dependent.

Returns:
the total amount of memory currently available for current and future objects, measured in bytes.

traceInstructions

public void traceInstructions(boolean on)
Enables/Disables tracing of instructions. If the boolean argument is true, this method suggests that the Java Virtual Machine emit debugging information for each instruction in the Java Virtual Machine as it is executed. The format of this information, and the file or other output stream to which it is emitted, depends on the host environment. The virtual machine may ignore this request if it does not support this feature. The destination of the trace output is system dependent.

If the boolean argument is false, this method causes the Java Virtual Machine to stop performing the detailed instruction trace it is performing.

Parameters:
on - true to enable instruction tracing; false to disable this feature.

traceMethodCalls

public void traceMethodCalls(boolean on)
Enables/Disables tracing of method calls. If the boolean argument is true, this method suggests that the Java Virtual Machine emit debugging information for each method in the Java Virtual Machine as it is called. The format of this information, and the file or other output stream to which it is emitted, depends on the host environment. The virtual machine may ignore this request if it does not support this feature.

Calling this method with argument false suggests that the Java Virtual Machine cease emitting per-call debugging information.

Parameters:
on - true to enable instruction tracing; false to disable this feature.