Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to garbage collect the JAVA virtual machine in Linux

Shulou Source: shulou.com Published: 2022-06-01 02:42:22 09月25日 Update

This article to share with you is about how to Java virtual machine garbage collection in Linux, Xiaobian feel quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.

JVM GC logs are written in substitution (>) rather than appending (>>), and the previous GC content is emptied the next time it is written to the same file. This causes us to restart JAVA services and lose historical GC logs.

-XX:+PrintGC

-XX:+PrintGCDetails

-XX:+PrintGCTimeStamps

-Xloggc:filename

Example

This writing will cause GC logs to be lost after JAVA service restart.

-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/data0/logs/gc.log

Here GC logs support two parameters: %p and %t:

%p will be replaced with the corresponding process PID

%t will be replaced with a time string in the format: Y-MM-DD_HH-MM-SS

In this way, no matter how you restart, GC history logs will not be lost.

The above is how to carry out garbage collection of JAVA virtual machine in Linux, Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Logs garbage writing history more knowledge articles services utility two content parameters characters strings that is work meetings files articles methods formats Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Huawei OPPO Reno MySQL Xiaomi