First, the runtime class
Each Java application has a Runtime
class instance that enables the application to connect to the environment in which it is running. The current runtime can be obtained by means of a getRuntime
method.
The application cannot create its own instance of the Runtime class.
GetRuntime ()
-
Returns the run-time object associated with the current Java application.
Runtime
most methods of a class are instance methods, and they must be called according to the current run-time object.
-
-
Return:
-
the object associated with the current Java application
Runtime
.
freememory ()
- Returns the amount of idle memory in a Java virtual machine. Calling
gc
a method may result
freeMemory
in an increase in the return value.
-
-
Return:
- The approximate total amount of current available memory to be used by the future allocation object, in bytes.
- (A wrong)
-
GC ()
run the garbage collector. Calling this method means that the Java virtual machine has made some effort to reclaim unused objects so that the memory currently occupied by these objects can be reused quickly. When control returns from a method call, the virtual machine has done its best to reclaim all discarded objects.
gc
the name represents the garbage collector. The virtual machine automatically performs the recycling process on a separate thread as needed, even without explicitly invoking the gc
method.
Method System.GC () is a traditional and convenient way to call this method.
GC is a non-static method,
So call the time with Runtime.getruntime (). GC ();
b wrong
Second, System class
GC ()
Run the garbage collector.
The invocation gc
method implies that the Java virtual machine has made some effort to reclaim unused objects so that the memory currently occupied by these objects can be reused quickly. When control is returned from a method call, the virtual machine has tried its best to reclaim space from all discarded objects.
The call is System.gc()
actually equivalent to the call: Runtime.getruntime (). GC ()
Select E
third, growheap () This function can not be found in the API, do not know whether there is no
Third, Java garbage collection (GC) mechanism
Http://www.cnblogs.com/aigongsi/archive/2012/04/06/2434771.html
Http://www.cnblogs.com/aigongsi/archive/2012/04/13/2446166.html
Question 11th (garbage collection)