简体   繁体   中英

How to find the peak memory usage in a maven build

I need to find out the peak memory usage of a maven build, can I rely on the final output given by successful maven build. Does 43M indicates the peak memory usage during the maven build. Thanks in advance.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.222 s
[INFO] Finished at: 2017-07-31T19:10:04+05:30
[INFO] Final Memory: 43M/636M
[INFO] ------------------------------------------------------------------------

Here :

Final Memory: 43M/636M

43M is the used memory and 636M the current allocated memory (heap size) by the JVM at the end of the build.
But these information could not give you the peak value.

Why the used memory ( 43M ) cannot be considered as the peak ?

  • Because the peak may have occurred before the end of the build.

Why the heap size ( 636M ) cannot be considered as the peak ?

  • Because the peak may be superior to the heap size if the GC reduced the heap size between the peak and the end of the build .
    It may be the case for a very long build that performs intensive tasks at the beginning and lighter tasks then.

  • Because the peak may be inferior to the heap size if the GC has increased the heap size until this value but the application never needs to consume as much as memory.

To get the memory peak during the execution of the maven build, monitor the Java application (maven execution) with any JVM tool designed for : JVisualVM or JConsole for example.

Here's an screenshot of a maven build of a Spring Boot application monitored by JVisualVM that shows that neither the heap size or the used size at the end of build are the peak value :

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM