aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Pool and GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String Pool and GC" Watch "String Pool and GC" New topic
Author

String Pool and GC

Gary Marshall
Ranch Hand

Joined: Feb 19, 2007
Posts: 121
All:
consider this code:


When this method completes, will the entry in the String Pool for "abc" remain or does it get deleted from the String Pool? If it remains, then when will it go away? Perhaps when the program ends? When the JVM stops running?

Thank you
Gary


G
Javin Paul
Ranch Hand

Joined: Oct 15, 2010
Posts: 294


Hi Gary,

Yes , "abc" will remain in String Pool even after this method gets completed and I beleive it only be removed when program gets terminated , Since String pool is gets created in Perm area of Java heap , it potentially exposes the chance of OutOfMemory in Perm space with huge string literal , anybody disagree ?

Thanks
Javin


SQL Query Interview Question
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
On the real exam, objects of type String will never be used in a GC question.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

+ For more details, have a look on this


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

Since JVM maintains this String Constant Pool, when we end up the JVM process, String constant Pool will be "removed"...


SCJP 6 [SCJP - Old is Gold]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Pool and GC