Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many strings are in jvm string pool intern

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?

like image 925
Zamir Avatar asked Dec 31 '14 10:12

Zamir


1 Answers

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.

like image 199
M A Avatar answered Oct 06 '22 01:10

M A