在 Eclipse 中增加 Java 堆大小 - 使用虚拟内存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15061364/
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-09-19 20:04:04  来源:igfitidea点击:

Increasing Java heap size in Eclipse - using virtual memory

javaeclipsevirtual-memory

提问by Masood Delfarah

I am running a program in Eclipse(Windows) and need a relatively huge size of memory. Passing the -Xmx1500mto the program seems not sufficient, while Eclipse does not permit me to assign a greater value. Having this configuration I get the out-of-memory exception. I increased the virtual memory size to 40GB. Isn't there a way to make this memory available to my program? I had easily done this in C#, for almost the same job.

我在 Eclipse(Windows) 中运行一个程序,需要相对较大的内存。将 传递-Xmx1500m给程序似乎还不够,而 Eclipse 不允许我分配更大的值。有了这个配置,我得到了内存不足的异常。我将虚拟内存大小增加到40GB. 有没有办法让我的程序可以使用这些内存?对于几乎相同的工作,我在 C# 中轻松完成了这项工作。

回答by cybye

you need to run a 64Bit vmto allow more than around -Xmx1500m

您需要运行64Bit vm以允许超过 -Xmx1500m

You may specify that in the Run-Settings for your programand do not need to apply it in the eclipse.ini which is for eclipse itself.

您可以在程序的运行设置中指定它,而不需要在 eclipse.ini 中应用它,因为 eclipse 本身。

BUT: it is not a good idea to give the java-vm more memory than the real (physical, free) memory on your system is, because the GC will walk through many areas of the memory when it runs and that will lead to reading/writing memory from/to disk - means swapping. And this again will lead to a very bad performance. In this case you should think about what is consuming the memory and if there is a way to manage this data externally - on disk or some MemoryBuffers.

但是:给 java-vm 提供比系统上实际(物理,空闲)内存更多的内存并不是一个好主意,因为 GC 在运行时会遍历内存的许多区域,这将导致读取/从/向磁盘写入内存 - 意味着交换。而这又会导致非常糟糕的表现。在这种情况下,您应该考虑什么正在消耗内存,以及是否有办法在外部管理这些数据 - 在磁盘或某些 MemoryBuffers 上。

回答by Sarath Kumar Sivan

You can configure heap size in "Run Configuration Dialog".

您可以在“运行配置对话框”中配置堆大小。

回答by Madhu V Rao

r u using 32 bit JVM or 64 bit? use 64 bit JVM. I am not sure about the size limitations on 64 bit , but definitely more than 32 bit.

ru 使用 32 位 JVM 还是 64 位?使用 64 位 JVM。我不确定 64 位的大小限制,但肯定超过 32 位。

try this: java -d64 -Xms512m -Xmx60g YourProgram

试试这个: java -d64 -Xms512m -Xmx60g YourProgram

it sets 60gb as the max heap size.

它将 60gb 设置为最大堆大小。

回答by asifsid88

Where you have unzipped the eclipse, look for eclipse.iniin that modify it enter image description here

在你解压 eclipse 的地方,寻找eclipse.ini修改它 在此处输入图片说明

回答by hthserhs

I think you need to increase the memory available to eclipse.

我认为您需要增加可用于 eclipse 的内存。

Modify -Xmxoption in the eclipse.inifile (in a Windows machine).

文件中的修改-Xmx选项eclipse.ini(在 Windows 机器中)。

回答by Mayur Chudasama

Go to your eclipse root folder where eclipse.exe file is left and you will find eclipse configuration file ( eclipse.ini ) open that file and you need following changesenter image description here

转到 eclipse.exe 文件所在的 eclipse 根文件夹,您会发现 eclipse 配置文件( eclipse.ini )打开该文件,您需要进行以下更改在此处输入图片说明