When I try to import in my main a serialized file the program stop working and throws: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
.
I know that this exception can be thrown because of a lack of memory but I don't think this is the reason in this case.
In my pc I have 8gb of RAM. This is the file .ini of Eclipse:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx7500m
-XX:+UseConcMarkSweepGC
-XX:-UseGCOverheadLimit
I noticed that although eclipse could use almost all the memory of my pc, when this error occurs, the RAM used is just 5Gb approximately. The file I'm trying to import is of 500Mb. The same program worked for many files of 350Mb. This is the line of code where the program crush, and is the first line of my program:
Classifier cls1 = (Classifier) weka.core.SerializationHelper.read("C:\\Users\\.....\\FileToImport.model");
For who knows, i'm using the Weka library. Thank you for the answers!
The 'eclipse.ini' file sets the memory for Eclipse itself not your program.
To set the memory for your program open the 'Run > Run Configurations' dialog. Find your program in the Java Application section and specify the -Xmx option you want in the 'Arguments > VM arguments' section.