如何在Java中释放内存?我使用system.gc
,但它仍然占用大量内存,当应用程序在csv中写入其增加并且每个csv大约需要0.6gb时,dokumen包含1000 ArrayList
try (FileWriter out = new FileWriter(new File("hasil\\hasil_binary" + s + ".csv"))) {
out.write("dokumen_data");
for (int i = 0; i < kamus.size(); i++) {
out.write("," + kamus.get(i));
}
out.write("," + "Class");
out.write("\n");
for (int i = 0; i < dokumen.size(); i++) {
out.write("dokumen_" + i);
for (int j = 0; j < dokumen.get(i).nt.size(); j++) {
out.write("," + dokumen.get(i).nt.get(j).getBinary());
}
out.write("," + dokumen.get(i).kategori);
out.write("\n");
}
out.close();
}
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}