This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

JXL,Out Of memory error

 
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
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reporting the solution. That's good to know!
 
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
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to Javaranch Sa Ja!
 
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
 
and POOF! You're gone! But look, this tiny ad is still here:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!