Strings and interning

String.substring does not copy or intern the substring, it points to the char array within the original base string, encumbering it so that it can't be garbage collected. The original base String is encumbered even if the substring is zero length.

As of Java 1.2 any interned String with no references may be garbage collected since they are weak references.

See post

The above site indicates String.inter stores utilizes Heap, some other sites indicate that interned Strings are stored in perm gen. Testing validates that interned Strings are stored in perm gen.

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout

Locks held on Oracle for hours after sessions abnormally terminated by node failure