I have an issue with java performance. I tried using GC1 but it didn't make things great. My only question is why the JVM keeps the java heap space even if it's not used ?
As you can see in the picture first the batch work finish around 10:30 but the garbage collector wasn't triggered to clean. So I did it manually at 10:52 then the used space was freed but heap (8GB) is still allocated by the JVM. Why ?

I've seen this trend too while doing the exact same thing that you did (and see here). The explanation is quite simple: JVM will not give back memory to the OS, even if it has lots of it free. I don't know the exact details of why this is so, but it has to do with the fact that asking memory back from the OS is expensive (this is ultra-simplified).
So I guess that the simple answer here is that - this is normal.
Here it is! I found where I have actually read about this.
G1GC perform whole-heap operations, such as global marking, concurrently with the application threads. This prevents interruptions proportional to heap.
Through G1GC is a new age Garbage collection algorithm, a switch from CMS or Old age garbage collection should be only made in case of following :
More details about G1 internal working can be found at : http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With