一个简单的"的Hello World"需要10G虚拟内存64位机VS 1G上的32位? [英] A simple "Hello World" needs 10G virtual memory on a 64-bit machine vs 1G at 32-bit?

查看:433
本文介绍了一个简单的"的Hello World"需要10G虚拟内存64位机VS 1G上的32位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行在我们的生产机器上一个简单的Java程序,我注意到,这程序吃掉更多的10G的virt。我知道虚拟内存是不是有关,但至少我想明白为什么这是必要的。

Running a simple Java program on our production machine, I noticed that this program eats up more 10G virt. I know that virtual memory is not that relevant, but at least I would like to understand why this is needed.

public class Main {
  public static void main(String[] args) {
        System.out.println("Hello World!");
        try {
                Thread.sleep(10000);
        } catch(InterruptedException e) {
                /* ignored */
        }
  }
}

下面有什么当我运行是说,小程序:

Heres what top is saying when i run that little program:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
18764 myuser    20   0 10.2g  20m 8128 S  1.7  0.1   0:00.05 java

有谁知道为什么会这样?

Does anyone know why this is happening?

的uname -a说:

uname -a says:

Linux m4fxhpsrm1dg 2.6.32-358.18.1.el6.x86_64 #1 SMP Fri Aug 2 17:04:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

在一个较旧的32位Linux的机器相同的程序只消耗大约1G的virt。旧的机器有4GB内存,新一32GB。

On an older 32bit-linux machine the same program consumes only about 1G virt. The old machine has 4GB RAM, the new one 32GB.

推荐答案

的的 被定义为机器的物理内存的百分比,它的生产服务器时下趋于初始堆和最大堆缺省大小有一大堆的。

The default sizes for initial heap and maximum heap are defined as a percentage of the machine's physical memory, of which a production server nowadays tends to have a whole lot.

您可以同时选择通过 -Xms和-Xmx命令行选项

这篇关于一个简单的"的Hello World"需要10G虚拟内存64位机VS 1G上的32位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆