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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
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: 11419
    
  16

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


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
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: 18896
    
  40

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: 11419
    
  16

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: 8829
    
    5
interesting topic, not on the exam.

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


Spot false dilemmas now, ask me how!
(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)