How to programmatically tell if ZST is in use?

Question:

Is there a way to tell programmatically if ZST is in use?

 

Answer:

When ZST is in use, the CodeCache is stored in the Heap (for Zing 20.08.0.0 and later).  CodeCache is stored off-heap when ZST is not in use.  This fact that be used to determine if ZST is enabled/disabled.

You can use a standard JDK MBean to display the CodeCache MemoryPool name.  For example, the TYPE attribute value will defined as follows:

ZST Status MBean "Type" Value
enabled java.lang:type=MemoryPool,name=CodeCache HEAP
disabled java.lang:type=MemoryPool,name=CodeCache NON_HEAP

Please see the difference between the two states from this JConsole screenshot:

codecache_zst_heap_vs_nonzst_nonheap.png

Alternatively, you can use the jmxterm command-line.

When ZST is enabled:

$>get -s -b java.lang:type=MemoryPool,name=Code\\ Cache Type
#mbean = java.lang:type=MemoryPool,name=Code Cache:
JAVA_HEAP

When ZST is disabled:

$>get -s -b java.lang:type=MemoryPool,name=Code\\ Cache Type
#mbean = java.lang:type=MemoryPool,name=Code Cache:
NON_JAVA_HEAP

Please note, this solution only applies to Zing versions from August 2020 and later (zing_20.08.0.0) as prior to this version, the CodeCache was always stored in the Heap.

Add Comment

Comments

0 comments

Please sign in to leave a comment.

Was this article helpful?
0 out of 0 found this helpful