且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-17 21:05:15

你需要运行一个 64Bit vm 允许超过大约-Xmx1500m



您可以在程序的运行设置中指定,而不需要应用它在eclipse.ini中,这是为了eclipse本身。但是,与系统中的真实(物理,免费)内存相比,给java-vm更多的内存不是一个好主意,因为GC将会走通过许多区域的内存,当它运行,并将导致读/写内存从/到磁盘 - 意味着交换。而这又会导致非常糟糕的表现。在这种情况下,您应该考虑消耗内存的情况,以及是否有一种外部管理数据的方法 - 在磁盘或一些MemoryBuffers上。


I am running a program in Eclipse(Windows) and need a relatively huge size of memory. Passing the -Xmx1500m to 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.

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

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

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.