tags:

views:

55

answers:

1

Hi,

What is the difference between CollectionUsage, PeakUsage, Usage fields in any memorypool bean ?
I saw these in the path of any application in a jconsole window:
mbeans tab > java.lang > memorypool > select any bean.
In the right hand side pane we can see these attributes.

+1  A: 

They're all described in the javadocs for MemoryPoolMXBean

Memory Usage

The getUsage() method provides an estimate of the current usage of a memory pool. For a garbage-collected memory pool, the amount of used memory includes the memory occupied by all objects in the pool including both reachable and unreachable objects.

In general, this method is a lightweight operation for getting an approximate memory usage. For some memory pools, for example, when objects are not packed contiguously, this method may be an expensive operation that requires some computation to determine the current memory usage. An implementation should document when this is the case.

Peak Memory Usage

The Java virtual machine maintains the peak memory usage of a memory pool since the virtual machine was started or the peak was reset. The peak memory usage is returned by the getPeakUsage() method and reset by calling the resetPeakUsage() method.

Collection Usage Threshold

Collection usage threshold is a manageable attribute only applicable to some garbage-collected memory pools. After a Java virtual machine has expended effort in reclaiming memory space by recycling unused objects in a memory pool at garbage collection time, some number of bytes in the memory pools that are garbaged collected will still be in use. The collection usage threshold allows a value to be set for this number of bytes such that if the threshold is exceeded, a collection usage threshold exceeded notification will be emitted by the MemoryMXBean. In addition, the collection usage threshold count will then be incremented.

The isCollectionUsageThresholdSupported() method can be used to determine if this functionality is supported.

A Java virtual machine performs collection usage threshold checking on a memory pool basis. This checking is enabled if the collection usage threshold is set to a positive value. If the collection usage threshold is set to zero, this checking is disabled on this memory pool. Default value is zero. The Java virtual machine performs the collection usage threshold checking at garbage collection time.

Some garbage-collected memory pools may choose not to support the collection usage threshold. For example, a memory pool is only managed by a continuous concurrent garbage collector. Objects can be allocated in this memory pool by some thread while the unused objects are reclaimed by the concurrent garbage collector simultaneously. Unless there is a well-defined garbage collection time which is the best appropriate time to check the memory usage, the collection usage threshold should not be supported.

The collection usage threshold is designed for monitoring the memory usage after the Java virtual machine has expended effort in reclaiming memory space. The collection usage could also be monitored by the polling and threshold notification mechanism described above for the usage threshold in a similar fashion.

Kevin
Thanks for the answer. It answered my question. I am now clear about it.