A Tale of Two Iterators

When you look at the most popular Java interview questions, you might encounter the one about fail-fast and fail-safe iterators: What’s the difference between fail-fast and fail-safe iterators? The simplified answer is that: Fail-fast iterator throws ConcurrentModificationException if the collection is modified while iterating, but fail-safe doesn’t. Even though it totally makes sense, it’s not…

Read more...

When Throughput Matters – Parallel GC

As I mentioned in one of the previous posts, Parallel Collector is also called Throughput Collector, because its main goal is to maximize overall throughput of the application. The two basic operations that Parallel Collector performs are Minor GC and Full GC. These are pretty straightforward.   Minor GC When Eden fills up, the young…

Read more...

User, Sys and Real Times in GC Log

Have you ever wondered what user, sys and real times in a GC log mean? Well, I have, a couple of times at least. Let’s say that we have the following line after Full GC entry: [Times: user=4.21 sys=0.03, real=0.75 secs] To find out what they represent, we should check UNIX command time first. time…

Read more...

GC Algorithms

As described in the previous post, we have four different garbage collectors available in HotSpot JVM. There are some significant differences between them, but the actual concepts behind the algorithms which are used to do the actual job are quite similar. In this short post, I will try to explain three basic algorithms: Mark-sweep Mark-sweep-compact…

Read more...

Why Server If It’s Not a Server?

Have you ever wondered why when you type java -version, you usually get something like that: java version “1.8.0_131” Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)   Why Server VM? For JVM, some machines are considered to be “client-class” and some are “server-class”. If the given machine…

Read more...

Garbage Collectors Overview

The current version of HotSpot JVM includes three types of garbage collectors: – Serial Collector – Parallel Collector – The Mostly Concurrent Collectors   All of them are generational ones, meaning that they take advantage of the way the heap is divided.   There are three main operations which garbage collector is responsible for: –…

Read more...

Yet Another Post About Java Heap Space

Generational Garbage Collectors JVM heap is divided into two different Generations. One is called Young and the second one is the Old (sometimes referred to as Tenured). The Young Generation is further separated into two main logical sections: Eden and Survivor spaces. There are also Virtual spaces for both Young and the Old Generations which…

Read more...

When Application Threads Can Be Stopped: Safepoints

There are two logical groups of threads in Java application: application threads performing application logic threads performing GC   When performing operations such as heap compaction, GC threads move some objects around and those objects cannot be used by any of the application thread, because their physical location may change. This leads to so called…

Read more...

PermGen and Metaspace

PermGen is an abbreviation for Permanent Generation and it’s a special heap space which is separate from the main Java heap where JVM keeps track of metadata of the classes which have been loaded. In Java 8 PermGen has been renamed to Metaspace – with some subtle differences. From our perspective, it is important to…

Read more...

Deoptimization

When looking at the output of -XX:+PrintCompilation JVM flag, it’s easy to spot some entries with “made not entrant” and “made zombie”. This indicates so called deoptimization. What it basically means is that the code which was previously compiled, has to be backed out.   Not entrant code Code can be made not entrant in…

Read more...