kshtjsnghl
kshtjsnghl

Reputation: 601

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!

Upvotes: 7

Views: 1072

Answers (2)

Michael McGowan
Michael McGowan

Reputation: 6608

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.

Upvotes: 4

Johan Sjöberg
Johan Sjöberg

Reputation: 49187

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.

Upvotes: 5

Related Questions