java.lang
Class Runtime
- java.lang.Object
-
- java.lang.Runtime
-
public class Runtime extends Object
Allows Java applications to interface with the environment in which they are running. Applications can not create an instance of this class, but they can get a singleton instance by invokinggetRuntime()
.- See Also:
System
-
-
Method Summary
Methods Modifier and Type Method and Description long
freeMemory()
Returns the amount of free memory resources which are available to the running program.void
gc()
Indicates to the virtual machine that it would be a good time to run the garbage collector.static Runtime
getRuntime()
Returns the singleRuntime
instance.long
totalMemory()
Returns the total amount of memory which is available to the running program.
-
-
-
Method Detail
-
freeMemory
public long freeMemory()
Returns the amount of free memory resources which are available to the running program.- Returns:
- the approximate amount of free memory, measured in bytes.
-
gc
public void gc()
Indicates to the virtual machine that it would be a good time to run the garbage collector. Note that this is a hint only. There is no guarantee that the garbage collector will actually be run.
-
getRuntime
public static Runtime getRuntime()
Returns the singleRuntime
instance.- Returns:
- the
Runtime
object for the current application.
-
totalMemory
public long totalMemory()
Returns the total amount of memory which is available to the running program.- Returns:
- the total amount of memory, measured in bytes.
-
-