I try to fill an ArrayList from a csv that contain 20000000 line , each line of the csv contain an id ,a string ,a int and a float. This array array list is an array list of Data(the costructor is below)
On the output of netbeans I see this error : Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded. I create this method :
public void fillArrayFromCsv(String path){
BufferedReader buffer1;
String line= "";
String fieldSplitFrom=",";
try{
buffer1= new BufferedReader(new FileReader(path));
while ((line = buffer1.readLine() ) != null) {
String[] data= line.split(fieldSplitFrom);
this.add(new Data(Integer.parseInt(data[0]),data[1],Integer.parseInt(data[2]),Float.parseFloat(data[3])));
}
}
catch(FileNotFoundException e){
}
catch (IOException ex){
}
}
the constructor of data is this :
public Data(int id, String f1, int f2, float f3) {
this.id = id;
this.f1 = f1;
this.f2 = f2;
this.f3 = f3;
}
I have no idea to fix it , probably I must to enlarge the Memory of the heap ?I run this code on a Macbook 12" with 8gb ram and 1,1 intel M processor, can I have a different result on another pc ?