1

We are trying to compare 2 CSV files which are of 3 gb size. We are receiving java heap memory error while trying to read these files with CSV map reader.can anybody please help me to solve this issue.

2
  • 2
    Please provide your code Commented Sep 3, 2016 at 13:47
  • If you are reading the entire contents of the CSV file into memory at once then you may encounter errors if you do not have enough memory to store the contents. Have you tried reading writing your program to read each file a line at a time and compare them? or write it to store 1 line from a file and search the entire other file for that content? Commented Sep 3, 2016 at 13:53

1 Answer 1

1

One option is to expand the memory for the heap. The initial heap size is 128 megs by default. Java has a flag you can pass it to increase this value.

You can initialize the heap size with -Xms[size] or you can give the JVM a maximum heap size with -Xmx[size].

In your case I would use -Xms to give the program more memory. For instance if you want the heap size to start out at 512 MB then when running the program you would run:

java -Xms512m programName 
Sign up to request clarification or add additional context in comments.

1 Comment

The heap is a 1/4 of main memory by default unless you are running the 32-bit windows version. If you need to process 3 GB of files you probably need 2-4 x this much heap to load at once.

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.