Hi,
I am facing a strange issue wherein a piece of code never releases the memory after finishing. The behavior is machine specific though, issue is seen on my VM running on Windows Server 2012-R2 (64-bit) with Intel Xeon CPU E5-2699, but doesn’t occur on my laptop running on Windows10 (64-bit) with Intel Core i7-7820HQ CPU. Both are running on latest version of Java 1.8 (64-bit).
Please find the sample program attached. I am basically just converting an excel file to pdf in a simple two line code which is in a separate method, I am calling it from Main, I believe once the method gets executed, it should free up the used memory, but it doesn’t happen in this case. I have created a separate thread from Main to watch the memory usage, I can see there that even after completion of processing, the memory usage never comes down. It happens only for this excel file though, for all other excel document memory usage goes up during processing but later comes down once done, something strange in this file.
Bad environment
java -Xmx512m -Xms512m Sample
Converting : Bad.xlsx
Total= 491 MB, free= 490 MB
Total= 491 MB, free= 475 MB
Total= 491 MB, free= 469 MB
Total= 491 MB, free= 399 MB
Total= 459 MB, free= 282 MB
Total= 466 MB, free= 240 MB
Total= 479 MB, free= 270 MB
Total= 489 MB, free= 282 MB
Done. Output : Bad.xlsx.pdf
Total= 494 MB, free= 295 MB
Total= 498 MB, free= 298 MB
Total= 497 MB, free= 297 MB
Total= 500 MB, free= 300 MB
Total= 499 MB, free= 299 MB
Total= 501 MB, free= 302 MB
Total= 500 MB, free= 301 MB
Total= 503 MB, free= 303 MB
Total= 502 MB, free= 302 MB
Total= 504 MB, free= 304 MB
Total= 503 MB, free= 304 MB
Total= 505 MB, free= 306 MB
Good environment :
java -Xmx512m -Xms512m Sample
Converting : Bad.xlsx
Total= 491 MB, free= 488 MB
Total= 491 MB, free= 475 MB
Total= 491 MB, free= 470 MB
Total= 479 MB, free= 432 MB
Total= 487 MB, free= 441 MB
Done. Output : Bad.xlsx.pdf
Total= 494 MB, free= 456 MB
Total= 493 MB, free= 455 MB
Total= 496 MB, free= 458 MB
Total= 495 MB, free= 457 MB
Total= 498 MB, free= 460 MB
Total= 497 MB, free= 459 MB
Total= 500 MB, free= 461 MB
Total= 499 MB, free= 461 MB
Total= 501 MB, free= 463 MB
Total= 501 MB, free= 462 MB
Total= 503 MB, free= 464 MB
Total= 502 MB, free= 464 MB
Total= 504 MB, free= 466 MB
Total= 503 MB, free= 465 MB
Total= 505 MB, free= 467 MB
Output completed (21 sec consumed) - Normal Termination
Sample.zip (428.7 KB)
Thanks,
Rajiv