What is the purpose of the Runtime class? The java runtime system can be accessed by the Runtime class. The runtime information – memory availability, invoking the garbage collector is possible by using Runtime class.
Knowing the free memory space:
Runtime.freeMemory() - Returns the free memory.
Runtime.maxMemory() - Returns the memory that JVM can use at the maximum.
Invoking garbage collector: Runtime.gc();
Some other facilities that are provided by Runtime class are:
- Reading data through key board - Using system properties and environment variables - Running non-java programs from within a java application.
|