Java 为什么我应该使用 64 位 JDK 而不是 32 位版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3669778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 03:19:38  来源:igfitidea点击:

Why should I use the 64-bit JDK over the 32-bit version?

64-bitjava

提问by Jonas

I use Eclipse and 64-bit Windows and develop Java desktop applications. So far, I have only used the 32-bit JDK, but is there any reason to change to 64-bit JDK for Java development?

我使用 Eclipse 和 64 位 Windows 并开发 Java 桌面应用程序。到目前为止,我只使用了 32 位 JDK,但是有什么理由改用 64 位 JDK 进行 Java 开发吗?

采纳答案by erickson

No, for your development-time activities, 32 bits is likely to be enough.

不,对于您的开发时间活动,32 位可能就足够了。

The newest JVMs support pointer compression, but otherwise, the 64-bit version of an application requires more memory to run. Only use 64-bits if your application needs to address more memory (32 bits should address 4 Gb, but OS considerations sometimes make this less).

最新的 JVM 支持指针压缩,但除此之外,64 位版本的应用程序需要更多内存才能运行。如果您的应用程序需要寻址更多内存,则仅使用 64 位(32 位应寻址 4 Gb,但操作系统考虑有时会减少这一点)。

Besides wasting a bit of memory, a 64-bit version shouldn't be a problem, but anecdotally, all of the inexplicable crashes of the usually rock-solid JVM I hear complaints about are in 64-bit versions. It could be the OS or other factors, but if you don't have a reason for 64 bits, why push your luck?

除了浪费一点内存之外,64 位版本应该不是问题,但有趣的是,我听到抱怨的通常坚如磐石的 JVM 的所有莫名其妙的崩溃都在 64 位版本中。这可能是操作系统或其他因素,但如果你没有 64 位的理由,为什么要靠运气呢?

回答by Jon Skeet

The primary reason would be if you wanted to write an app capable of using a large amount of memory (e.g. over 4GB, or whatever the per-process limit on your operating system is).

主要原因是如果您想编写一个能够使用大量内存(例如超过 4GB,或操作系统上的每个进程限制)的应用程序。

回答by larsolsen

Try this:

尝试这个:

public class Benchmark {
    public static void main(String args[]) {
        long time = System.currentTimeMillis();
        for (int a = 1; a < 900000000; a++) {
            for (int b = 1; b < 20; b++) {
            }
        }
        long time2 = System.currentTimeMillis() - time;
        System.out.println("\nTime counter stopped: " + time2);
    }
}

In 32 and 64 bit and laugh at the difference.

在 32 位和 64 位并笑有区别。