Pyohwan Jang
Pyohwan Jang

Reputation: 51

How do I know when to tuning Heap size when using G1 GC?

In Oracle's G1 GC document, G1 GC does not recommend tuning JVM options because throughput and latency are stable.

https://docs.oracle.com/javase/10/gctuning/garbage-first-garbage-collector-tuning.htm#JSGCT-GUID-0BB3B742-A985-4D5E-A9C5-433A127FE0F6

However, I could not find a page in the document that how appropriate server heap size should be. purpose of the server and the amount of traffic vary. It can be a simple Restful API, or it can be a long time consuming task. Therefore, the heap size should be different depending on the server application. Also, if the heap size is insufficient, Full GC will occur multiple times and eventually cause serious problems.

  1. How do you determine the appropriate initial heap size?
  2. When should you increase the heap size?
  3. Are there methods and tools to monitor abnormal signs?

Upvotes: 2

Views: 507

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533820

I would

  • create a benchmark of a workload you would like to optimise for
  • performance tuning the application for allocations for this workload. This can change everything else you do, so do it first. e.g. using Flight Recorder.
  • try the application with different heap sizes, and see at what point adding more memory doesn't seem to make a difference.
  • try more workloads if you have time.

How do you determine the appropriate initial heap size?

What is the size the application grows to almost immediately? If you benchmark with larger sizes does it appear to help?

When should you increase the heap size?

WHen after determining your application doesn't have a memory leak, and is reasonably tuned, the server needs more memory or would run faster if it had more memory.

Are there methods and tools to monitor abnormal signs?

For a tool you can run continuously, you could start with jstat

Upvotes: 1

Related Questions