• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pool of Interns Memory(String literals)

 
Niranjan Prasad
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to the best of my knowledge, it doesn't.
 
Niranjan Prasad
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody throw some light on this.
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am guessing the lost literals would be garbage collected when the JVM feels like
 
Henry Wong
author
Marshal
Pie
Posts: 21427
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niranjan Prasad wrote:Can anybody throw some light on this.


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

Henry
 
Niranjan Prasad
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Garbage Collection happens on Heap Memory
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How strings objects are cleaned..or GC'ed in some or the other way is not part of the exam.
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting topic, not on the exam.

let's move it to the intermediate forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic