简体   繁体   English

java.lang.OutOfMemoryError:Eclipse中的Java堆空间,无论设置如何

[英]java.lang.OutOfMemoryError: Java heap space in Eclipse, regardless of the settings

I am testing a simple recommender system built using Mahout in Eclipse. 我正在测试使用Eclipse中的Mahout构建的简单推荐系统。

If the preferences file is too big I am getting this error: 如果首选项文件太大,则会出现此错误:

    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.substring(String.java:1939)
    at java.lang.String.subSequence(String.java:1972)
    at com.google.common.base.Splitter$SplittingIterator.computeNext(Splitter.java:612)
    at com.google.common.base.Splitter$SplittingIterator.computeNext(Splitter.java:522)
    at com.google.common.base.AbstractIterator.tryToComputeNext(AbstractIterator.java:64)
    at com.google.common.base.AbstractIterator.hasNext(AbstractIterator.java:59)
    at com.google.common.base.AbstractIterator.next(AbstractIterator.java:74)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processLine(FileDataModel.java:408)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processFile(FileDataModel.java:363)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.buildModel(FileDataModel.java:259)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.reload(FileDataModel.java:231)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:221)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:169)
    at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:149)
    at com.predictionmarketing.itemrecommend.ItemRecommend.main(ItemRecommend.java:35)

The file contains about 5 millions preference points. 该文件包含约500万个偏好点。

I have already read several messages about this issue and my eclipse.ini is the following 我已经阅读了一些有关此问题的消息,以下是我的eclipse.ini:

-startup
../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
3000m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=3000m
-Xms3000m
-Xmx6000m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts

Basically I added -Xmx6000m and changed -Xmx and MaxPermSize (both) to 3000m. 基本上,我添加了-Xmx6000m并将-Xmx和MaxPermSize(两者)都更改为3000m。 I am not very fluent in Java so I don't know if the settings are correct, but during the execution I can see something like 我不太熟练使用Java,所以我不知道设置是否正确,但是在执行过程中,我会看到类似

Heap size: 55M of total 3017M max 5996 mark 55M

Which seems to reflect the settings. 这似乎反映了设置。

The weird thing is that I don't see much increase of the heap size during execution, also the free memory in my computer (mac os) is around 800M. 奇怪的是,我在执行期间没有看到堆大小的太大增加,而且我的计算机(mac os)中的可用内存大约为800M。

Where is the problem? 问题出在哪儿? If the preferences file is smaller, everything works fine. 如果首选项文件较小,则一切正常。

The eclipse.ini settings are only used for the Eclipse application. eclipse.ini设置仅用于Eclipse应用程序。

When you Run a Java application from Eclipse you need to go to 'Run > Run Configurations'. 从Eclipse运行Java应用程序时,需要转到“运行>运行配置”。 Find your application in the Java application list. 在Java应用程序列表中找到您的应用程序。 On the 'Arguments' tab enter your memory settings in the 'VM arguments' section. 在“参数”选项卡上的“ VM参数”部分中,输入您的内存设置。

Read Java Heap Space - How does -Xmx work exactly? 阅读Java堆空间--Xmx如何正常工作?

and

http://javarevisited.blogspot.gr/2011/05/java-heap-space-memory-size-jvm.html http://javarevisited.blogspot.gr/2011/05/java-heap-space-memory-size-jvm.html

Java Heap is not the same for every system i think that in Windows for example the default java Heap is 60 Mb Java堆对于每个系统都不相同,例如,我认为在Windows中,默认的Java堆为60 Mb

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

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