Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JXL,Out Of memory error

 
Prashanth Bhanu
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reporting the solution. That's good to know!
 
Sa Ja
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow
Thank you 10000 of times You made my day with this answer.
Thank you Thank you Thank you
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to Javaranch Sa Ja!
 
Cibiarasu Ravichandran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic