Java OutOfMemory on Mac, running on Windows

I have an application that loads data from a CSV file and shows it in a table. The application works correctly for all files (no matter what size it is) in windows, but only works with files below 8 MB on a Mac, any other file is bigger than it does to me "java.lang.OutOfMemoryError: Java empty space " I debugged the application to make sure it reads the .csv file and it does, but after a while it will fail with this error.

I did some research and tried using -Xmx and -Xms to increase the Java heap size, but still getting the same error.

The following code is where the application crashes after adding some arrays of information to mainHashtable:

while(reader.readRecord()){ ArrayList<CSVEntry> list = new ArrayList<CSVEntry>(); for(int i = 0; i < colscount; i++){ CSVEntry entry = new CSVEntry(headerNames[i], reader.get(i)); list.add(entry); } mainHashtable.put(recordcount, list); recordcount++; } 

Any suggestions that will help me solve this problem will be appreciated.

+4
source share
2 answers

-Xmx is the correct answer. Java has odd defaults for the maximum heap size depending on the platform (sometimes up to 8 MB).

If your application is bundled with a JAR with the INF directive of the main class, the following should work for you:

java -Xmx256m -jar myapp.jar

+4
source

Use the Java Bundler to create an application.
On the "Properties" tab in the VM options, insert: "-Xmx512m" without quotes

+1
source

All Articles