Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory footprint for a java application

In our application, we allow users to upload/download data through an excel sheet and we use Apache POI to read and write these excel sheets.
We were planning to migrate all our xls sheets to xlsx, but came to know during the process that the memory footprint of XSSF(for xlsx) through Apache POI is significantly high.

As a result, we wanted to stress test this, and verify that moving to xlsx won’t give us frequent OutOfMemory exceptions. Any pointers, on how we can effectively record the memory footprints, while we stress test this functionality with larger excel(xlsx) files.

Thanks!

like image 866
kshtjsnghl Avatar asked Jun 07 '11 15:06

kshtjsnghl


2 Answers

A simple approach is to use a tool such as jconsole or jvisualvm (which is shipped with the JVM) to manually monitor the memory consumption.

You could also periodically use the runtime API to measure memory consumption.

like image 83
Johan Sjöberg Avatar answered Sep 22 '22 20:09

Johan Sjöberg


As @Johan mentioned, you can use a profiler or leverage some combination of the methods maxMemory, totalMemory, and freeMemory from the Runtime. If those results indicate that memory footprint is indeed a problem, Apache POI does offer another option with lighter footprint for XSSF. It's harder to use, so I wouldn't recommend using it unless your profiling results indicate that you have to, but it could help.

like image 43
Michael McGowan Avatar answered Sep 21 '22 20:09

Michael McGowan