user2328774
user2328774

Reputation: 31

JVM makes a full GC then there is no more system memory left

i have a Java web application,when the JVM makes a FGC,there is no more memory left,then swap will be used, and the load is growing fast. And i can't undersatand why,anybody could help me?

Upvotes: 1

Views: 171

Answers (3)

Aleš
Aleš

Reputation: 9028

Enable Full GC logging so you can see what is happening in your Heap.

  • Compute Live Data Set, Allocation Rate, and Promotion Rate. This will tell you if you need a bigger Heap or if your eg. Young Gen is too small, or if your Survivor spaces are overflowing, etc.
  • Compute total GC time, it should be <5% of total running time.

Use -XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion

Upvotes: 0

Steven Schlansker
Steven Schlansker

Reputation: 38536

Either your Java heap size is too low for the working set of data you are processing, or you have a memory leak which is consuming the memory that could otherwise be used for useful processing.

Your first point of attack could be to use a profiler to understand exactly what is consuming memory. JVisualVm is a somewhat bare-bones but competent profiler. From there, you can make decisions about whether you need to allocate more memory (via -Xmx VM arguments), fix memory leaks, or make algorithmic improvements.

Upvotes: 1

devnull
devnull

Reputation: 123668

You seem to have set the maximum heap size (-Xmx) high enough that the JVM doesn't have any memory left for garbage collection. As such, the system runs out of RAM and starts swapping to disk.

You can begin by either reducing -Xmx or adding some RAM to your system and figure what's making your app consume so much memory.

Upvotes: 2

Related Questions