aspose file tools*
The moose likes Other Open Source Projects and the fly likes JXL,Out Of memory error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "JXL,Out Of memory error" Watch "JXL,Out Of memory error" New topic
Author

JXL,Out Of memory error

Prashanth Bhanu
Ranch Hand

Joined: Sep 25, 2003
Posts: 110
Hi Friends,

I'm fetching huge number of records say 140,000 records from the database and write it to excel.I'm using jxl for this purpose.

But i keep getting

CoordinatorCo W HMGR0152W: CPU Starvation detected. Current thread scheduling delay is 7 seconds.


and while calling



I'm facing memory issue found in the server console.

Exception data: java.lang.OutOfMemoryError
at jxl.write.biff.MemoryDataOutput.write(MemoryDataOutput.java:72)
at jxl.write.biff.File.write(File.java:149)
at jxl.write.biff.RowRecord.writeCells(RowRecord.java:324)
at jxl.write.biff.SheetWriter.write(SheetWriter.java:479)
at jxl.write.biff.WritableSheetImpl.write(WritableSheetImpl.java:1431)
at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:915)

I'm getting records in batch of 30,000(inside do loop).And making sure each worksheet will have not more than 60000 records.I strongly suspect

Because all the queries are fired inside the loop and the above error occurs when write method is called.I've posted part of my code as shown below.



I appriciate your help in this regard.Thanks in advance

Prashu




Prashanth Bhanu
Ranch Hand

Joined: Sep 25, 2003
Posts: 110
Hi Friends,

Problem is resoved.I'm posting solution if it may be of some use for somebody in the future.



Instead of keeping the binary content in memory(which needs huge memory incase of large data).A temperory file is created to temporarly keep the data before writting.

Hope this helps......

Thanks
Prashu
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41497
    
  53
Thanks for reporting the solution. That's good to know!


Ping & DNS - my free Android networking tools app
Sa Ja
Greenhorn

Joined: Nov 21, 2009
Posts: 1
Wow
Thank you 10000 of times You made my day with this answer.
Thank you Thank you Thank you
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

And welcome to Javaranch Sa Ja!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Cibiarasu Ravichandran
Greenhorn

Joined: Jun 27, 2012
Posts: 1
Hi ,

Thanks for the solution.

I am facing the similar problem with jxl download. I am able to download excel up to size of 6MB, above 6 MB it throws out of memory exception.

As per the solution in this forum(code below)



I tried,but the above code seems to work partially . i.e, I am able to download up to 8 MB now and above 8 MB it throws out of memory exception again.

So with this solution, I am able download 2 mb more.(from 6 MB to 8 MB)

Is there any other way to completely elliminate out of memory exception from jxl.

Thanks a lot!!

Regards,
Cibi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JXL,Out Of memory error