Posts

Garbage Collection in Java

Image
Garbage Collection When a Java object becomes unreachable to the program, then it is subjected to garbage collection. The main use of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. Advantages can be  : Increase productivity  as no need to worry about memory issues. Program integrity .  Garbage collection is an important part of Java's security strategy. Java programmers are unable to accidentally crash the Java virtual machine by incorrectly freeing memory. Automatic Garbage Collection Automatic garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects. An in use object, or a referenced object, means that some part of your program still maintains a pointer to that object. An unused object, or unreferenced object, is no longer referenced b...

Metaspace in Java 8

Image
This is how Heap Structure look like in Java 6 Permanent Generation The pool containing all the reflective data of the virtual machine itself, such as  class  and  method  objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains  metadata  required by the JVM to describe the  classes  and  methods  used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here. Classes may get collected (unloaded) if the JVM finds they are no longer needed and space may be needed for other classes. The permanent generation is included in a full garbage collection Region of Java Heap for JVM Class Metadata. Hotspot’s internal representation of Java Classes. Class hierarchy inf...