1

Does GC runs on run-time constant pool?

If yes, when? If no, what happen if the string pool is full with string literals?

I did google but dint find any relevant thing on this problem also tried with program on my machine.

Amit
  • 497
  • 3
  • 8
  • 24

1 Answers1

0

Your question is too low-level because it can be resolved simply by observing that a string literal is always reachable, being referenced from the class where it appears.

The constant pool happens to be subject to garbage collection since Java 6, when it was moved to the regular heap. This comes into play only if your code uses many String.intern() calls, which can add strings to the constant pool.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436