简体   繁体   English

控制台用尽了Java堆空间内存,但是Eclipse的设置不相同

[英]Console runs out of java heap space memory, but Eclipse does not with same settings

I am running a java program that loads very large (almost 2Gb) files. 我正在运行一个Java程序,该程序加载了非常大的文件(几乎2Gb)。 It runs fine within Eclipse as long as I set the max heap space -mx3700m or higher. 只要我将最大堆空间设置为-mx3700m或更高,它就可以在Eclipse中正常运行。 Eclipse executes with javaw, and when I watch the memory usage in Task Manager I can see the Private Working Set memory hitting around 3.7Gb. Eclipse使用javaw执行,当我在Task Manager中观察内存使用情况时,我可以看到Private Working Set内存达到3.7Gb。

The problem comes when I create a runnable jar and try to run from the command line. 当我创建一个可运行的jar并尝试从命令行运行时,问题就来了。 I've tried using both java and javaw, with max heap space all the way up to -mx7000m (my computer has 8Gb RAM). 我试过同时使用java和javaw,最大堆空间一直到-mx7000m(我的计算机有8Gb RAM)。 But I always run out of memory. 但是我总是内存不足。 When I monitor in Task Manager, the memory hits a ceiling at 2.08Gb and never goes beyond. 当我在任务管理器中监视时,内存达到2.08Gb的上限,并且永不超过。

I'm using the same 64bit jre in both cases - 1.8.0_144. 在两种情况下,我都使用相同的64位jre-1.8.0_144。

I need to be able to run the jar file from the command line, but I'm not sure what I'm doing wrong. 我需要能够从命令行运行jar文件,但是我不确定自己做错了什么。 Any help would be very much appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

我会尝试使用Xmx参数运行它,例如:

java -jar -Xmx4096M file.jar

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

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