4

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 has) in windows, but it only works with the files that are lower than 8MB on Mac, any other file bigger than that throws me a "java.lang.OutOfMemoryError: Java heap space". I debugged the application to make sure that it was reading the .csv file and it does, but after a while it jush crashes with that error.

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

The following code is where the application crashes after adding some of the arrays with information to the 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 help me solve this issue will be gladly appreciated.

3
  • How are you launching the application? From the command line? From an IDE? Commented Jul 21, 2011 at 22:46
  • 2
    I am pretty sure it is something with some kind of configuration where Java is allowed a specific memory limit, and you only need to increase that limit. Commented Jul 21, 2011 at 22:47
  • I'm creating a jar file to run it on Mac, but now I'm launching the application from the IDE to try to fix the error. Commented Jul 22, 2011 at 14:09

2 Answers 2

4

-Xmx is the correct answer. Java has odd defaults for maximum heap space depending on the platform (sometimes as low as 8MB).

If your application in bundled in a JAR with a Main-Class INF directive, the following should work for you:

java -Xmx256m -jar myapp.jar

Sign up to request clarification or add additional context in comments.

2 Comments

You were right, seems like I was using -Xmx in wrong place. Thanks
The order matter: while java -jar app.jar -Xmx200M works on Linux, the Xmx is ignored on a Mac if you write params in this order
1

Use the Java Bundler to generate an app
In the Properties tab, in the VM Options, insert: "-Xmx512m" without the quotes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.