I have a Spring boot program using OpenJdk (jdk1.8) running at server, consuming about 200 or 300 million data from kafka and write to csv files each day. Less than 2 hours after starts up, it using more than 6GB memory. So I dump heap using jmap histo. And find that int[] array using 2.6GB and byte[] array using 1.3GB.
But I defined neither int[] nor byte[] in my project. I'm using spring kafka(org.springframework.kafka, version2.3.3) consume kafka message, opencsv(com.opencsv, version4.6) write csv.
Any one knows the reason?
Below is part of my code:
public <T> Boolean parseDataToFile(String filePath, List<T> data) throws IOException, CsvDataTypeMismatchException, CsvRequiredFieldEmptyException {
if (data == null || data.size() <= 0) {
return false;
}
File file = new File(filePath);
//创建父目录
boolean mkdirs = file.getParentFile().mkdirs();
Writer writer = null;
try {
writer = new FileWriter(filePath, true);
StatefulBeanToCsv beanToCsv = new StatefulBeanToCsvBuilder(writer).withThrowExceptions(false).withSeparator(',').build();
beanToCsv.write(data);
return true;
} finally {
if (writer != null) {
writer.flush();
writer.close();
}
}
}
Addtion: at Instance view, most(more than 90%) of them are none-used(retained size are 0), so it can be GCed? But why not? What are these int[] byte[] data?






