src/java.management/share/classes/sun/management/MemoryPoolImpl.java
changeset 49558 b2bd13eafc1c
parent 47216 71c04702a3d5
equal deleted inserted replaced
49557:7b00ac6c11ab 49558:b2bd13eafc1c
    53     private MemoryManagerMXBean[] managers;
    53     private MemoryManagerMXBean[] managers;
    54 
    54 
    55     private long  usageThreshold;
    55     private long  usageThreshold;
    56     private long  collectionThreshold;
    56     private long  collectionThreshold;
    57 
    57 
    58     private boolean usageSensorRegistered;
    58     private boolean usageSensorRegistered; // VM-initialized to false
    59     private boolean gcSensorRegistered;
    59     private boolean gcSensorRegistered;    // VM-initialized to false
    60     private Sensor  usageSensor;
    60     private final Sensor usageSensor;
    61     private Sensor  gcSensor;
    61     private final Sensor gcSensor;
    62 
    62 
    63     MemoryPoolImpl(String name, boolean isHeap, long usageThreshold,
    63     MemoryPoolImpl(String name, boolean isHeap, long usageThreshold,
    64                    long gcThreshold) {
    64                    long gcThreshold) {
    65         this.name = name;
    65         this.name = name;
    66         this.isHeap = isHeap;
    66         this.isHeap = isHeap;
    70         this.collectionThreshold = gcThreshold;
    70         this.collectionThreshold = gcThreshold;
    71         this.usageThresholdSupported = (usageThreshold >= 0);
    71         this.usageThresholdSupported = (usageThreshold >= 0);
    72         this.collectionThresholdSupported = (gcThreshold >= 0);
    72         this.collectionThresholdSupported = (gcThreshold >= 0);
    73         this.usageSensor = new PoolSensor(this, name + " usage sensor");
    73         this.usageSensor = new PoolSensor(this, name + " usage sensor");
    74         this.gcSensor = new CollectionSensor(this, name + " collection sensor");
    74         this.gcSensor = new CollectionSensor(this, name + " collection sensor");
    75         this.usageSensorRegistered = false;
       
    76         this.gcSensorRegistered = false;
       
    77     }
    75     }
    78 
    76 
    79     public String getName() {
    77     public String getName() {
    80         return name;
    78         return name;
    81     }
    79     }
   288      * usage of a memory pool is crossing the usage threshold.
   286      * usage of a memory pool is crossing the usage threshold.
   289      * The VM will not trigger this sensor in subsequent crossing
   287      * The VM will not trigger this sensor in subsequent crossing
   290      * unless the memory usage has returned below the threshold.
   288      * unless the memory usage has returned below the threshold.
   291      */
   289      */
   292     class PoolSensor extends Sensor {
   290     class PoolSensor extends Sensor {
   293         MemoryPoolImpl pool;
   291         final MemoryPoolImpl pool;
   294 
   292 
   295         PoolSensor(MemoryPoolImpl pool, String name) {
   293         PoolSensor(MemoryPoolImpl pool, String name) {
   296             super(name);
   294             super(name);
   297             this.pool = pool;
   295             this.pool = pool;
   298         }
   296         }
   314     /**
   312     /**
   315      * CollectionSensor will be triggered and cleared by the VM
   313      * CollectionSensor will be triggered and cleared by the VM
   316      * when the memory usage of a memory pool after GC is crossing
   314      * when the memory usage of a memory pool after GC is crossing
   317      * the collection threshold.
   315      * the collection threshold.
   318      * The VM will trigger this sensor in subsequent crossing
   316      * The VM will trigger this sensor in subsequent crossing
   319      * regardless if the memory usage has changed siince the previous GC.
   317      * regardless if the memory usage has changed since the previous GC.
   320      */
   318      */
   321     class CollectionSensor extends Sensor {
   319     class CollectionSensor extends Sensor {
   322         MemoryPoolImpl pool;
   320         final MemoryPoolImpl pool;
   323         CollectionSensor(MemoryPoolImpl pool, String name) {
   321         CollectionSensor(MemoryPoolImpl pool, String name) {
   324             super(name);
   322             super(name);
   325             this.pool = pool;
   323             this.pool = pool;
   326         }
   324         }
   327         void triggerAction(MemoryUsage usage) {
   325         void triggerAction(MemoryUsage usage) {