Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Out of Memory Exception

Thread view: 
praveenkumarr@gmail.com - 19 Oct 2005 11:16 GMT
Out of memory exception from  a JSP File..

Description:
    Getting out of memory exception while exporting a CSV file frmom JSP

    While clicking the download button, it forwards to a struts action
class and from there it calls PO and DAO for database calls and
executing the query to download the data...
and the data is put in a List..and finally a JSP is converting the List
object to one StringBuffer object and writes it to an CSV file.

    Expected Solutions:
    1. I need to keep the session active until it gets downloaded..bcos it
takes time to download the file, mean -while the session get destroyed
    2. Performance tuning to Fix that error

Please help me out at the earliest...
Thanks in advance..!
Andrew Thompson - 19 Oct 2005 13:59 GMT
> Please help me out at the earliest...

How much money is my urgent assistance worth to you?

[ It might be better to be *patient* and wait for
the free answers. ]
Roedy Green - 19 Oct 2005 14:03 GMT
On 19 Oct 2005 03:16:40 -0700, praveenkumarr@gmail.com wrote or quoted

>Getting out of memory exception while exporting a CSV file frmom JSP

If alternate code to write CSV files would help you, see
http://mindprod.com/jgloss/csv.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Ben_ - 19 Oct 2005 21:14 GMT
> Out of memory exception from  a JSP File..
>
[quoted text clipped - 6 lines]
> and the data is put in a List..and finally a JSP is converting the List
> object to one StringBuffer object and writes it to an CSV file.

How large is this resulting StringBuffer ?
You're better to progressively produce the result in chunks than store the
complete result in memory.

> Expected Solutions:
> 1. I need to keep the session active until it gets downloaded..bcos it
> takes time to download the file, mean -while the session get destroyed

You're kidding ?!? How long is the session timeout (it's usually 30 minutes
by default) ? How long does it take to produce the CSV ?
Web is request/reply and must be fast. It's not for running long operations.

> 2. Performance tuning to Fix that error
>
> Please help me out at the earliest...
If your description is accurate, you are in too deep trouble for getting a
working solution without a review of the design. You better hire someone to
do the job.

> Thanks in advance..!
Roedy Green - 20 Oct 2005 01:48 GMT
>How large is this resulting StringBuffer ?
>You're better to progressively produce the result in chunks than store the
>complete result in memory.

This is the way CSVWriter works. It squirts output a field at a time
to a BuffereOutputWriter.

If the CSV writing is not too deeply buried in somebody else's code
swapping the CSV writer may be your fastest way to solving. it.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

praveenkumarr@gmail.com - 20 Oct 2005 09:22 GMT
Thanks for ur reply..!
The size of the dowloading may differ from 1MB- 5MB..
Reg. Session Timeout i have put session.setMaxInactiveInterval(-1) in
the Action Action Class, but still its not working i believe...
The download may take around 45mins sometimes and am getting the "Page
Cannot be displayed" after that particular period of time...
Kindly help me please......
Ben_ - 20 Oct 2005 17:18 GMT
Try Roedy's component or change the way you produce the CSV to not build it
with a SingleString. It comes as no surprise to me that a MB large string
wouldn't fit in memory...
Roedy Green - 22 Oct 2005 02:13 GMT
>Try Roedy's component or change the way you produce the CSV to not build it
>with a SingleString. It comes as no surprise to me that a MB large string
>wouldn't fit in memory...

You could be in a thrashing situation shuffling objects around like
mad to make room for an ever-growing StringBuilder.  As a quick fix,
construct the StringBuilder (not StringBuffer) the right size to
start. Also consider reusing it with setLength(0) if you are using it
more or less continuously.

If you don't know, put some effort into making a reasonable estimate
based on past history and what you know about the coming case.

Also consider serialising the creating of CSV files so you don't try
to construct 20 of them at once.

See http://mindprod.com/jgloss/queue.html

However I think you will find doing it with my CSVWriter will solve
your problem without any fanatic tweaking.

see http://mindprod.com/jgloss/csv.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

praveenkumarr@gmail.com - 22 Oct 2005 10:00 GMT
Thanks Roedy, Thanks for ur reply and suggestion, will try building
thru StringBuilder Class..


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.