aspose file tools
The moose likes Java in General and the fly likes Pool of Interns Memory(String literals) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Pool of Interns Memory(String literals)" Watch "Pool of Interns Memory(String literals)" New topic
Author

Pool of Interns Memory(String literals)

Niranjan Prasad
Ranch Hand

Joined: Aug 13, 2005
Posts: 62
We all know String literals are allocated memory in Pool Interns.My doubt is how Java deallocates the memory after the usage of String literal.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9940
    
    6

to the best of my knowledge, it doesn't.


Never ascribe to malice that which can be adequately explained by stupidity.
Niranjan Prasad
Ranch Hand

Joined: Aug 13, 2005
Posts: 62
Can anybody throw some light on this.
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
I am guessing the lost literals would be garbage collected when the JVM feels like
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16681
    
  19

Niranjan Prasad wrote:Can anybody throw some light on this.


As Fred said, it doesn't get garbage collected...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Niranjan Prasad
Ranch Hand

Joined: Aug 13, 2005
Posts: 62
Garbage Collection happens on Heap Memory
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9940
    
    6

Niranjan Prasad wrote:Garbage Collection happens on Heap Memory
I don't see your point. String literals are a special case. They are handled a little different than other objects, so they are not eligible for GC.

There may be some strange, esoteric case where is it possible, but none that I am aware of.
Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
How strings objects are cleaned..or GC'ed in some or the other way is not part of the exam.


SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8712
interesting topic, not on the exam.

let's move it to the intermediate forum...


Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pool of Interns Memory(String literals)
 
Similar Threads
String constant pools and Strings on heap
Is Kathy&Bert book wrong? Or my understanding wrong?
String objects
Pool and Heap's of Confusion
String new object clarification