Out of Memory Exception

P

praveenkumarr

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

Andrew Thompson

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

Ben_

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.

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

praveenkumarr

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

Ben_

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

Roedy Green

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
 
P

praveenkumarr

Thanks Roedy, Thanks for ur reply and suggestion, will try building
thru StringBuilder Class..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top