How can we know how many string objects are in liter string pools.?

How can we know how many string objects are in the liter string pools.

Is there any mechanism or java code that will give me the number of String objects that are current in the string pool?

+6
source share
3 answers

is there any mechanism or java code that will give me the number of String objects that are current in the string pool.

No, such a mechanism does not exist in the JDK.

+4
source

there is no mechanism, but if you want to know more about the row pool than

http://www.journaldev.com/797/what-is-java-string-pool

0
source

No, there is no direct mechanism for accessing the String pool, as it is privately supported by the String class. But we can check and see if the pool contains a specific String object using: -

StringObject.intern(); //Returns a canonical representation for the string object. 

Although there may be a workaround for this, I have never tried or used this approach. You can continue and investigate a little.

This is due to using VisualVM to view memory values ​​at runtime,

http://java.dzone.com/articles/visualvm-see-whats-your-heap

http://netbeans.dzone.com/vvm-displaying-java-memory-pool-stats

0
source

Source: https://habr.com/ru/post/970430/


All Articles