dhatim / fastexcel

Generate and read big Excel files quickly
Other
647 stars 116 forks source link

CPU & Memory Full Utilization in Tomcat Server #317

Closed zanesonsona closed 10 months ago

zanesonsona commented 11 months ago

Is it just me? or someone has encounter the same problem. When used in a tomcat project and writing large number of data, it hogs both CPU and memory up to 100% utmost.

Just wondering if am I using it the wrong way, or it is what it is.

meiMingle commented 10 months ago

If you can provide the relevant code, or provide detailed context where this issue occurs, then we'd love to help resolve the issue

zanesonsona commented 10 months ago

try(OutputStream os = new FileOutputStream("Test.xlsx"); Workbook wb = new Workbook(os, "Test", "1.0");){ Worksheet testSheet= wb.newWorksheet("Sheet 1");

writeBody(testSheet); testSheet.finish(); wb.finish(); } catch(Exception e){ System.out.println("Error Message: " + e); }

private void writeBody(Worksheet ws){ for(int r = 7; r<=600000; r++){ for(int c = 0; c<=48; c++){ ws.value(r, c, "Hello World"); } } }

It is just a simple writing instead I created a writeBody method with just a simple loop assuming a large data of 600,000 rows.

ochedru commented 10 months ago

Your heap settings are probably too low: the Java GC kicks in and saturates the CPU. All worksheet cells are kept in memory until the call to finish(). Try increasing your max heap setting.