Reputation: 67
How to read large(95+MB) excel workbook with more then 10 sheets in java using POI library without increasing JVM(like -Xmx1G). If we run jar file without increasing VM got OutOfMemory error. How can I optimize this issue in coding itself instead of increasing VM?
Upvotes: 2
Views: 2688
Reputation: 718658
There are no clever "optimizations" that will allow you to continue with your current approach and run using less memory.
You are going to need to change your program so that it does not load the entire workbook into memory.
As @M.Deinum points out, Apache POI provides an alternative way to process Excel files where you get a sequence of parser events rather than an in-memory representation of each entire spreadsheet. Switching from the in-memory model to the event-based model will entail a significant amount of recoding of your application. But if you cannot afford the memory you have no other practical alternatives.
Upvotes: 5