File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes freeing up of memory used by strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "freeing up of memory used by strings" Watch "freeing up of memory used by strings" New topic
Author

freeing up of memory used by strings

Sarada Bhasker
Ranch Hand

Joined: Sep 11, 2000
Posts: 94
When is the memory used up by strings released in a servlet or JSP service method?
Will it make any difference if it is a string literal or string
created using new String() method;
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
Just like for every other object, Strings can be GCed when they have no reference. Your local variables can be GCed when the response is finished.
The trickiest chance for running low on memory would be if you store lots of objects in a session - they won't be GCed until the session is destroyed.
String literals are kept around and won't be freed as long as the Class is loaded.
Bill

------------------
author of:


Java Resources at www.wbrogden.com
 
Consider Paul's rocket mass heater.
 
subject: freeing up of memory used by strings
 
Similar Threads
Strings
String's intern method
String
Difference between s = "" and new String("a")
Out of Memory Error - optimisation tips?