Re: JavaMemoryModel: String literals and String.intern()

From: Eliot Moss (moss@cs.umass.edu)
Date: Sat Apr 17 2004 - 09:18:41 EDT


I suppose I stand corrected ... but I should add that the JVMs I tend to
work with never unload classes, so string constants in loaded code go into
a global table, from which they are never removed.

If strings are actually interned, then there is an interning table
somewhere. To be able to collect such strings, the table would have to
operate using weak pointers (one of the java.lang.Reference
classes). Perhaps it is indeed coded that way. However, if any thread has
hold of such an object (e.g., via having synchronized on it but not yet
released the lock), then the object will not be collected.

Regards -- Eliot

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:05 EDT