aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC for string pools Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC for string pools" Watch "GC for string pools" New topic
Author

GC for string pools

Peter Heide
Ranch Hand

Joined: Nov 04, 2006
Posts: 31
I am wondering if the Strings in the string pool are getting eligible for garbage collection or are living there until the program ends.

Given the following, is the string s one or two times time eligible?



SCJA
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

The SCJP exam doesn't cover GC for String objects. From here

Unlike most objects, String literals always have a reference to them from the String Literal Pool. That means that they always have a reference to them and are, therefore, not eligible for garbage collection.


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Peter Heide
Ranch Hand

Joined: Nov 04, 2006
Posts: 31
Thank you Ankit Garg for your answer, I think you are absolutely right!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GC for string pools