Java Heap Sapce Release

I have a java performance issue. I tried using GC1 but it didn't do any good. My only question is, why does the JVM keep the java heap space even when not in use? As you can see in the picture, the batch processing ends around 10:30 at first, but the garbage collector does not start to clean up. So I did it manually at 10:52, then the used space was freed, but the heap (8GB) is still allocated by the JVM. What for? Java memory problem

+3


source to share


3 answers


I've seen this trend too, doing the exact same thing as you (and see here). The explanation is quite simple: JVM will not return OS memory even if it has a lot of free memory. I don't know the exact details why

, this is the case, but it has to do with the fact that requesting memory from is OS

expensive (it's ultra-simplistic).

So, I think the simple answer is that this is ok.



Here it is! I found where I actually read about this .

+3


source


The G1GC performs full heap operations such as global marking concurrently with application threads. This prevents interruptions proportional to the heap.

Through the G1GC, a new new generation garbage collection algorithm, the transition from a CMS or garbage collector in the old age should be done only in the following cases:



  • Over 50% of the Java heap is occupied by live data.
  • The frequency of distribution or advancement of an object varies greatly.
  • Unwanted prolonged garbage collection or pressing (more than 0.5 to 1 second)

More information on the inner workings of the G1 can be found at: http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html

+1


source


GC is only triggered if the application requires additional memory. gc is an expensive task and vm will decide when to run it. If you suspect that your program is consuming memory and the GC isn't freeing it, that's a concern. If you can share a test case that demonstrates this issue, we'll work around and fix this issue.

0


source







All Articles