After studying the internal elements of java strings, I was embarrassed by what is called "perm space". Initially, I realized that it contained String literals, as well as class metadata, as described in this question .
I also read about the String.intern() method and put String in a string pool, returning a link to a unique instance. I understand that this is the same string pool that stores String literals that exist in the real JVM space. It did not seem to me that the βperm spaceβ could be modifiable (it is, after all, constant, right?). But then I found this question where the top voted EJP comment from the accepted answer explains that
Inner strings have been GC-capable for several years.
Assuming that the GC runs on a perm space that doesn't seem very constant. How is this reconciled? Does GC check everything in perm space? Does GC check everything in the string pool, including string literals from the source? Is there a second row pool for inner rows? Does the Civil Code know just to look at internships during the collection? Or is this comment flawed and interns a string that prevents it from ever being GC'd (in my opinion, it is not)?
java garbage-collection string jvm string-interning
Ryan Haining Aug 09 '13 at 17:40 2013-08-09 17:40
source share