1

Possible Duplicate:
Garbage collection behaviour for String.intern()
How does Java store Strings and how does substring work internally?

According to me the String reference when declared as null doesn't deletes the entry from String literal pool and i want to know how we can clear it .

    String object="csk";// creates an Object in Java Heap and makes an entry String Literal Pool .
    object=null// however make this reference to null object .

//but it doesn't deletes an entry from String literal .I doubt if it deletes an entry from Literal Pool

Community
  • 1
  • 1

2 Answers2

2

String literals (WeakHashMap) are also stored in heap memory called the "permgen" heap. need to configure in JVM to find and collect dynamically loaded classes that are no longer needed, and this may cause String literals to be garbage collected. and or when JVM performas the Full gc.

varsha
  • 304
  • 8
  • 22
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Xavi López Feb 04 '13 at 13:36
  • 1
    Just edited my post according to question – varsha Feb 05 '13 at 07:12
0

An excerpt from How does Java store Strings and how does substring work internally?:

Strings in the pool can be garbage collected (meaning that a string literal might be removed from the pool at some stage if it becomes full)

Community
  • 1
  • 1
maffo
  • 1,393
  • 4
  • 18
  • 35