src/share/vm/services/lowMemoryDetector.hpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 







  25 // Low Memory Detection Support
  26 // Two memory alarms in the JDK (we called them sensors).
  27 //   - Heap memory sensor
  28 //   - Non-heap memory sensor
  29 // When the VM detects if the memory usage of a memory pool has reached
  30 // or exceeded its threshold, it will trigger the sensor for the type
  31 // of the memory pool (heap or nonheap or both).
  32 //
  33 // If threshold == -1, no low memory detection is supported and
  34 // the threshold value is not allowed to be changed.
  35 // If threshold == 0, no low memory detection is performed for
  36 // that memory pool.  The threshold can be set to any non-negative
  37 // value.
  38 //
  39 // The default threshold of the Hotspot memory pools are:
  40 //   Eden space        -1
  41 //   Survivor space 1  -1
  42 //   Survivor space 2  -1
  43 //   Old generation    0
  44 //   Perm generation   0


 266           detect_low_memory(pool);
 267         }
 268       }
 269     }
 270   }
 271 
 272 };
 273 
 274 class LowMemoryDetectorDisabler: public StackObj {
 275 public:
 276   LowMemoryDetectorDisabler()
 277   {
 278     LowMemoryDetector::disable();
 279   }
 280   ~LowMemoryDetectorDisabler()
 281   {
 282     assert(LowMemoryDetector::temporary_disabled(), "should be disabled!");
 283     LowMemoryDetector::enable();
 284   }
 285 };


   1 /*
   2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_SERVICES_LOWMEMORYDETECTOR_HPP
  26 #define SHARE_VM_SERVICES_LOWMEMORYDETECTOR_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "services/memoryPool.hpp"
  30 #include "services/memoryService.hpp"
  31 
  32 // Low Memory Detection Support
  33 // Two memory alarms in the JDK (we called them sensors).
  34 //   - Heap memory sensor
  35 //   - Non-heap memory sensor
  36 // When the VM detects if the memory usage of a memory pool has reached
  37 // or exceeded its threshold, it will trigger the sensor for the type
  38 // of the memory pool (heap or nonheap or both).
  39 //
  40 // If threshold == -1, no low memory detection is supported and
  41 // the threshold value is not allowed to be changed.
  42 // If threshold == 0, no low memory detection is performed for
  43 // that memory pool.  The threshold can be set to any non-negative
  44 // value.
  45 //
  46 // The default threshold of the Hotspot memory pools are:
  47 //   Eden space        -1
  48 //   Survivor space 1  -1
  49 //   Survivor space 2  -1
  50 //   Old generation    0
  51 //   Perm generation   0


 273           detect_low_memory(pool);
 274         }
 275       }
 276     }
 277   }
 278 
 279 };
 280 
 281 class LowMemoryDetectorDisabler: public StackObj {
 282 public:
 283   LowMemoryDetectorDisabler()
 284   {
 285     LowMemoryDetector::disable();
 286   }
 287   ~LowMemoryDetectorDisabler()
 288   {
 289     assert(LowMemoryDetector::temporary_disabled(), "should be disabled!");
 290     LowMemoryDetector::enable();
 291   }
 292 };
 293 
 294 #endif // SHARE_VM_SERVICES_LOWMEMORYDETECTOR_HPP