Too much CPU time garbage collector

I developed a web application that processes a huge amount of data and takes a long time to complete?

So, now I am doing the profiling of my application, and I noticed a very bad thing about the GC.
When a full GC has occurred, it stops the entire process for 30-40 seconds.

I wonder if there is a way to improve this. I do not want to drag my processor so much time only in the GC. Below are some details that may be helpful:

  • I am using Java 1.6.0.23
  • My application takes up 20 GB of maximum memory.
  • Every 14 minutes, a complete GC occurs.
  • The memory before the GC is 20 GB, and after the GC - 7.8 GB
  • The memory used in the CPU (i.e. displayed in the task manager) is 41 GB.
  • After the process is completed (the JVM is still running), the used memory is 5 GB and the free memory is 15 GB.
+5
source share
5 answers

The fewer things you have new, the less things you need to collect.

Suppose you have class A. You can include a reference to another instance of class A in this way. So you can make a β€œfree list” of instances of A. Whenever you need A, just pick one from the free list. If the free list is empty, then newone.

When you no longer need it, click it in the free list.

It can save a lot of time.

+3
source

, JVM . , , , , , . , JVM .

- , , , , , , , GCed.

JVM , ( A B, B C, C D.... Z A). , .

, ( null )....

+5

64- , :

-XX:+UseCompressedOops 64- 32

G1GC CMS:

-XX:+UseG1GC -

: -Xms5g -Xmx5g

( ):

-XX:MaxGCPauseMillis=100 -XX:GCPauseIntervalMillis=1000

. Java HotSpot

+4

, , System.gc() ( ). , -, , , .

+4

, GC, :

  • (= -)
  • finalize()

, finalize(), Java, Java , ++ ( , ++ ).

, , , / ( ) . :

, , . , , GC .

, -, , . , , GC .

+3

All Articles