Browse Source

* 调整读写默认大小,防止大批量写的时候可能会full gc

pull/2177/head
Jiaju Zhuang 3 years ago
parent
commit
04c9402e3f
  1. 6
      src/main/java/com/alibaba/excel/util/WorkBookUtil.java

6
src/main/java/com/alibaba/excel/util/WorkBookUtil.java

@ -26,8 +26,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
*/ */
public class WorkBookUtil { public class WorkBookUtil {
public static final int ROW_ACCESS_WINDOW_SIZE = 500;
private WorkBookUtil() {} private WorkBookUtil() {}
public static void createWorkBook(WriteWorkbookHolder writeWorkbookHolder) throws IOException { public static void createWorkBook(WriteWorkbookHolder writeWorkbookHolder) throws IOException {
@ -39,7 +37,7 @@ public class WorkBookUtil {
if (writeWorkbookHolder.getInMemory()) { if (writeWorkbookHolder.getInMemory()) {
writeWorkbookHolder.setWorkbook(xssfWorkbook); writeWorkbookHolder.setWorkbook(xssfWorkbook);
} else { } else {
writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook, ROW_ACCESS_WINDOW_SIZE)); writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook));
} }
return; return;
} }
@ -47,7 +45,7 @@ public class WorkBookUtil {
if (writeWorkbookHolder.getInMemory()) { if (writeWorkbookHolder.getInMemory()) {
workbook = new XSSFWorkbook(); workbook = new XSSFWorkbook();
} else { } else {
workbook = new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE); workbook = new SXSSFWorkbook();
} }
writeWorkbookHolder.setCachedWorkbook(workbook); writeWorkbookHolder.setCachedWorkbook(workbook);
writeWorkbookHolder.setWorkbook(workbook); writeWorkbookHolder.setWorkbook(workbook);

Loading…
Cancel
Save