java.lang.OutOfMemoryError: Java heap space in Eclipse, regardless of settings

advertisements

I am testing a simple recommender system built using Mahout in Eclipse.

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.

I have already read several messages about this issue and my eclipse.ini is the following

-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. 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

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.

Where is the problem? If the preferences file is smaller, everything works fine.


The eclipse.ini settings are only used for the Eclipse application.

When you Run a Java application from Eclipse you need to go to 'Run > Run Configurations'. Find your application in the Java application list. On the 'Arguments' tab enter your memory settings in the 'VM arguments' section.