• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory Leak in JSP?  RSS feed

 
Rathnavadivel Muthukumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp that adds a huge String (30KB) to itself 10 times. I monitored the Memory Usage while i ran this JSP and noticed this: The memory usage increases exponentially but never gets released even after i close the browser that called the JSP. This happens even if i assign the String to null & call System.runFinalization() as the last lines in the JSP. Is this bcoz there is a problem with the app server i use (IIS with ServletExec) or is this an inherent problem with JSPs.
 
Mark Simms
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it's a well-known Java problem.......
don't perform string concatenation unless you are using StringBuffer objects !!!
then convert to string at the last minute using the string buffer's "toString()" method.
 
Rathnavadivel Muthukumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the immediate reply Mark,
I Tried the StringBuffer concatenation too. The problem is the memory allocated to objects in JSP is not getting freed up after the JSP has been rendered & even if the object is assigned to null. My feeling is that the object(s) exists as long as the session is active. Is this what is supposed to happen. (Note that i am not explicitly putting any object in the session).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!