Posts

Showing posts with the label HotSpot

How Serial Garbage Collector works in the HotSpot virtual machine

Image
The Serial Garbage Collector was one of the first garbage collectors in the HotSpot VM. While this collector is running, the application is suspended and continues to run only after garbage collection has stopped. Application memory is divided into three spaces: Young generation . Objects are created in this particular area of memory. Old generation . Objects that survive "minor garbage collection" are moved to this area of memory. Permanent generation . Here metadata about objects, Class data sharing (CDS), String pool are stored. The permanent area is divided into two: read-only and read-write. Obviously, in this case, the read-only area is never cleaned up by the garbage collector. The Young generation memory area consists of three areas: Eden and two smaller Survivor spaces - To space and From space. Most objects are created in the Eden area, with the exception of very large objects that cannot be placed in it and therefore are immediately placed in the Old ge...

What flavors of garbage collectors are implemented in the HotSpot virtual machine

Image
The Java HotSpot VM provides developers with four different garbage collectors to choose from: Serial is the easiest option for applications with low data volume and low latency requirements. At the moment, it is used relatively rarely, but on weak computers it can be selected by the virtual machine as the default collector. The use of Serial GC is enabled with the -XX:+UseSerialGC option. Parallel - inherits assembly approaches from the sequential collector, but adds parallelism to some operations, as well as the ability to automatically adjust to the required performance parameters. The parallel collector is enabled with the -XX:+UseParallelGC option. C oncurrent Mark Sweep (CMS) - aims to reduce maximum latency by performing some of the garbage collection work in parallel with the main threads of the application. Suitable for dealing with relatively large amounts of data in memory. The use of CMS GC is enabled with the -XX:+UseConcMarkSweepGC option. Garbage-First (G1) - de...