简体   繁体   English

使用JVM内存默认值运行Java Web应用程序

[英]Running java web application with JVM memory defaults

I am running my java web application using my IDE (IntelliJ) and doing a heavy bulk operation, which by now is running since around 5 hours or so. 我正在使用我的IDE(IntelliJ)运行我的Java Web应用程序,并进行了大量操作,该操作到目前为止已经运行了大约5个小时左右。 It includes a lot of database inserts, a lot of object creations, I guess it is also kind of CPU intense, and it is not at all heavy on the network. 它包括许多数据库插入,许多对象创建,我想它也是CPU密集型的,并且在网络上一点也不繁重。

A current look in my task manager (windows) gives me these numbers: 我在任务管理器(windows)中的当前外观为我提供了这些数字:

  • CPU: 35% CPU:35%
  • RAM: 49% 内存:49%
  • IO: 1% IO:1%
  • Network: 0% 网络:0%
  • GPU: 5% GPU:5%

Usage by processes, is ... 按流程使用是...

... orderd by CPU-usage it is like this: ...按CPU使用率排序是这样的:

  1. "PostreSQL Server" “ PostreSQL Server”
  2. "IntelliJ IDEA (9)" “ IntelliJ IDEA(9)”
  3. "Google Chrome (16)" “谷歌浏览器(16)”

... ordered by memory consumption: ...按内存消耗排序:

  1. "IntelliJ IDEA (9)" “ IntelliJ IDEA(9)”
  2. "Google Chrome(16)" “谷歌浏览器(16)”
  3. "OpenJDK Platform binary" “ OpenJDK平台二进制文件”

My subjective feeling is definitely, that my computer is hard working, I hear the fan go non-stop and also when switching between windows I witness lag. 我的主观感觉肯定是,我的计算机工作正常,我听到风扇不停地运转,并且在切换窗口时我看到了滞后。

I wonder however, why my task manager is not showing that my computer is using one of the resources to its' full extent? 但是,我想知道为什么我的任务管理器没有显示我的计算机正在完全使用其中一种资源?

I guess it means, that my application is already using the maximum available memory (limited by the JVM heapsize)? 我猜这意味着,我的应用程序已经在使用最大可用内存(受JVM堆大小限制)吗? I did not specify this explicitly, and running 我没有明确指定,并且正在运行

java -XX:+PrintFlagsFinal -version | findstr HeapSize

yields these defaults for me: 为我产生这些默认值:

uintx ErgoHeapSizeLimit                         = 0                                   {product}
    uintx HeapSizePerGCThread                       = 87241520                            {product}
    uintx InitialHeapSize                          := 268435456                           {product}
    uintx LargePageHeapSizeThreshold                = 134217728                           {product}
    uintx MaxHeapSize                              := 4271898624                          {product}
openjdk version "1.8.0_202"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.202-b08, mixed mode)

I have got 16 GB physical RAM on my machine, do you suggest I should set an explicit value for xms and xmx as described here? 我有16 GB我的机器上的物理内存,你建议我应该设定一个明确的价值xmsxmx这里描述? How can I increase the JVM memory? 如何增加JVM内存?

By default, JVM uses 1/4 of available physical memory as MaxHeapSize . 默认情况下,JVM使用1/4的可用物理内存作为MaxHeapSize If you need more, then you can specify that via -Xmx . 如果需要更多,则可以通过-Xmx进行指定。 It really depends on your application and its needs. 这实际上取决于您的应用程序及其需求。

Note that IDEA itself may consume a lot of memory since it's also Java application. 请注意,IDEA本身也是Java应用程序,因此可能会消耗大量内存。 If you're worried about performance you should profile your application first (start by something like VisualVM) and then tune as necessary. 如果您担心性能,则应首先对应用程序进行配置(以类似VisualVM的方式启动),然后根据需要进行调整。

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

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