How do you list a string that has been internalized in jvm?

Possible duplicate:
Java - tell me if String is interned?

I would like to have a list of lines that jvm has learned, either because they are literal, because the intern method is what they were called. How can I generate it?

+3
source share
2 answers

You can get the total size of all interned strings as:

$ jmap -permstat 543
Attaching to process ID 543, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 19.1-b02-334
14584 intern Strings occupying 1603648 bytes.
finding class loader instances ..Warning: skipping invalid TLAB for thread t@44819
...
+1
source

How can I create it?

You cannot run the program. An API for repeating the pool of inner rows does not exist.


You could in theory do this using a debug agent. This will include:

  • , String .
  • , str == str.intern().

( ) , . , , , .

+1

All Articles