简体   繁体   English

如何在maven构建中找到峰值内存使用情况

[英]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. 我需要找出maven构建的峰值内存使用情况,我可以依赖成功的maven构建给出的最终输出。 Does 43M indicates the peak memory usage during the maven build. 43M是否表示maven构建期间的峰值内存使用量。 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. 43M是在构建结束时由JVM使用的内存和636M当前分配的内存(堆大小)。
But these information could not give you the peak value. 但是这些信息无法给你带来最高价值。

Why the used memory ( 43M ) cannot be considered as the peak ? 为什么用过的内存( 43M )不能算作峰值?

  • Because the peak may have occurred before the end of the build. 因为峰值可能在构建结束之前发生。

Why the heap size ( 636M ) cannot be considered as the peak ? 为什么堆大小( 636M )不能被视为峰值?

  • 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 . 因为如果GC减少了构建的峰值和结束之间的堆大小,峰值可能会优于堆大小。
    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. 因为如果GC增加了堆大小直到此值,峰值可能不如堆大小,但应用程序永远不需要消耗尽可能多的内存。

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. 要在执行maven构建期间获取内存峰值,请使用为JVisualVM或JConsole设计的任何JVM工具监视Java应用程序(maven执行)。

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 : 以下是JVisualVM监控的Spring Boot应用程序的maven构建的屏幕截图,显示堆大小或构建结束时使用的大小都不是峰值:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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