Release the memory occupied by objects

Java's automatic recovery mechanisms

When the garbage collector in java judge has no references to object at any time, we will call the object's finalize method to release the memory space occupied by

When constructing a class constructor can cover a class method in order to finalize its class to execute some code when garbage, such as the release of resources.

 

Overview of the JVM gc

gc That means jvm garbage collection mechanism for the release of those objects are no longer using the memory occupied. java language does not require jvm have gc, gc work also does not specify how. But common jvm have gc, gc and most use a similar algorithm to perform memory management and collection operations.

After fully understanding the garbage collection algorithms and implementation process in order to effectively optimize its performance. Some garbage collection dedicated to a particular application. For example, real-time applications is to avoid interruption of garbage collection, and most OLTP applications, pay attention to overall efficiency. Understand garbage collection algorithms workload applications and jvm support, we can optimize the allocation of the garbage collector.

The purpose is to clear the garbage collection object is no longer in use. gc activity by determining whether the object is an object reference to determine whether to collect the object. gc must first determine whether the object is when you can collect. Two commonly used methods are reference counting and object reference traversal.

Guess you like

Origin www.cnblogs.com/wudidamowang666/p/11073231.html