File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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(
at jxl.write.biff.File.write(
at jxl.write.biff.RowRecord.writeCells(
at jxl.write.biff.SheetWriter.write(
at jxl.write.biff.WritableSheetImpl.write(
at jxl.write.biff.WritableWorkbookImpl.write(

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


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......

Ulf Dittmer

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

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

Joined: Jun 24, 2003
Posts: 3275

And welcome to Javaranch Sa Ja!

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

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!!

I agree. Here's the link:
subject: JXL,Out Of memory error
It's not a secret anymore!