I am profiling an application and the use of intern to input strings really helps. What I want to find is a good number to use for the object pool so I will not have performance penalty. How can I know how many strings were inserted into the intern pool?
I am running some production trace, I cannot really count the input.
Does the JVM offer an api for this?
Starting with JDK7, you can use the -XX:+PrintStringTableStatistics
JVM flag to print information about the size of the string table, such as the number of buckets and the size of a bucket.
You can also use the jmap
tool by calling the command jmap -heap *process_id*
which would show at the end the number of strings interned and the total size (also requires JDK7+).
Check this blog post for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With