When trying to get the content of the URL bellow, OutOfMemoryError is thrown. http://www.pondokwan-klub.si/Aktualno\pdk-zagorje%202003-rezultati.xls This is my code, that uses POI: HSSFWorkbook wb = new HSSFWorkbook(in); , where in is InputStream reading content of the above URL
This is happening because the excel file that is being referenced is too large. The way POI is working is that if anything needs to be done with an excel file, the entire file has to be read into memory first. This is where the problem is. If the excel file is very large... i.e. the workbook contains lots of sheets of data with lots of rows and columns, the ENTIRE data would first be read into memory. Then we can do any modifications with the Workbook object. Then we have to write the entire data back from memory to the excel file in one shot. You cannot write to a file in parts. Unfortunately, this is the way POI works. :o( I guess no one envisioned POI being used to such a large extent where excel files are toooo large that there is a shortage of memory. One short term solution for this problem is to increase your app server memory. But this is a short term solution cause as soon as the excel file becomes larger, the OutOfMemory Error would again be thrown. :o( A way needs to be developed by POI guys to only read a certain amount of data into memory, work with it and then write it back and then take the next chunk of data. Maybe data being processed should be broken on the basis of Sheets within a workbook. This way the data to be read into memory is limited to a sheet. Best Regards, Bonson
Samo, Is the file linked in your description still available?
The sample file is long since gone to assess any performance problems. I am going to close this bug as invalid, but Bonson's comments are right. This is how POI works at the moment. Jason