Problem
I have an .xlsx file with lots of formulas. I want to transform this file to a new .xlsx file with all formulas replaced with its absolute value. Why? probably not related with this question.
What did I do?
My target was to perform this task in as low amount of heap memory as possible. So I used a combination of apache POI XSSF event API to read the source file and SXSSF API to write the output file. It worked well.
Observations
All measurements are taken using JProfiler 10
When I run my code to convert a file of around 25K+ rows (with around 25K * 23 formulas), it used around 250 MB of heap space at the peak. Now I ran the same command with -Xmx24M
and the code is managed to run within this memory limit which is significantly lower than the first run.
Questions
- If my code can already manage to run within this low memory limit why it took 250MB+ of ram in the first run?
- Is it possible to limit this particular piece of code to limit its memory consumption within a low limit even though the Xmx is not set?