P
puneet.bansal
Hi,
In a servlet, I am reading from the database and writing to PrintWriter
stream. The database returns around 50,000 rows. I create a
StringBuffer object just once outside the ResultSet loop and then
append all my database data to it and write it to PrintWriter at the
end of each iteration. In the beginning of each iteration I set the
length of the StringBuffer to zero. I think this is an optimized code
as there are no object creations inside the loop and I am re-using the
same object for each iteration. But still when that loop is executed
the memory consumption goes up by 50MB. I am using StringBuffers
everywhere in the loop. Any idea what could be wrong. I am running my
code on Websphere 5.
Thanks.
Puneet
In a servlet, I am reading from the database and writing to PrintWriter
stream. The database returns around 50,000 rows. I create a
StringBuffer object just once outside the ResultSet loop and then
append all my database data to it and write it to PrintWriter at the
end of each iteration. In the beginning of each iteration I set the
length of the StringBuffer to zero. I think this is an optimized code
as there are no object creations inside the loop and I am re-using the
same object for each iteration. But still when that loop is executed
the memory consumption goes up by 50MB. I am using StringBuffers
everywhere in the loop. Any idea what could be wrong. I am running my
code on Websphere 5.
Thanks.
Puneet