/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/interfaceSupport.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/mutexLocker.hpp"
#include "services/lowMemoryDetector.hpp"
#include "services/management.hpp"
bool has_requests = false;
for (int i = 0; i < num_memory_pools; i++) {
}
}
}
return has_requests;
}
// No need to hold Service_lock to call out to Java
for (int i = 0; i < num_memory_pools; i++) {
}
}
}
}
// This method could be called from any Java threads
// and also VMThread.
bool has_pending_requests = false;
for (int i = 0; i < num_memory_pools; i++) {
pool->usage_threshold());
}
}
if (has_pending_requests) {
}
}
// This method could be called from any Java threads
// and also VMThread.
return;
}
{
pool->usage_threshold());
if (sensor->has_pending_requests()) {
// notify sensor state update
}
}
}
// Only called by VMThread at GC time
return;
}
{
if (sensor->has_pending_requests()) {
// notify sensor state update
}
}
}
// recompute enabled flag
bool enabled = false;
for (int i=0; i<num_memory_pools; i++) {
enabled = true;
break;
}
}
}
_sensor_obj = NULL;
_sensor_on = false;
_sensor_count = 0;
_pending_clear_count = 0;
}
// When this method is used, the memory usage is monitored
// as a gauge attribute. Sensor notifications (trigger or
// clear) is only emitted at the first time it crosses
// a threshold.
//
// High and low thresholds are designed to provide a
// hysteresis mechanism to avoid repeated triggering
// of notifications when the attribute value makes small oscillations
// around the high or low threshold value.
//
// The sensor will be triggered if:
// (1) the usage is crossing above the high threshold and
// the sensor is currently off and no pending
// trigger requests; or
// (2) the usage is crossing above the high threshold and
// the sensor will be off (i.e. sensor is currently on
// and has pending clear requests).
//
// Subsequent crossings of the high threshold value do not cause
// any triggers unless the usage becomes less than the low threshold.
//
// The sensor will be cleared if:
// (1) the usage is crossing below the low threshold and
// the sensor is currently on and no pending
// clear requests; or
// (2) the usage is crossing below the low threshold and
// the sensor will be on (i.e. sensor is currently off
// and has pending trigger requests).
//
// Subsequent crossings of the low threshold value do not cause
// any clears unless the usage becomes greater than or equal
// to the high threshold.
//
// If the current level is between high and low threhsold, no change.
//
if (is_over_high &&
((!_sensor_on && _pending_trigger_count == 0) ||
_pending_clear_count > 0)) {
// low memory detected and need to increment the trigger pending count
// if the sensor is off or will be off due to _pending_clear_ > 0
// Request to trigger the sensor
if (_pending_clear_count > 0) {
// non-zero pending clear requests indicates that there are
// pending requests to clear this sensor.
// This trigger request needs to clear this clear count
// since the resulting sensor flag should be on.
_pending_clear_count = 0;
}
} else if (is_below_low &&
((_sensor_on && _pending_clear_count == 0) ||
(_pending_trigger_count > 0 && _pending_clear_count == 0))) {
// memory usage returns below the threshold
// Request to clear the sensor if the sensor is on or will be on due to
// _pending_trigger_count > 0 and also no clear request
}
}
// When this method is used, the memory usage is monitored as a
// simple counter attribute. The sensor will be triggered
// whenever the usage is crossing the threshold to keep track
// of the number of times the VM detects such a condition occurs.
//
// High and low thresholds are designed to provide a
// hysteresis mechanism to avoid repeated triggering
// of notifications when the attribute value makes small oscillations
// around the high or low threshold value.
//
// The sensor will be triggered if:
// - the usage is crossing above the high threshold regardless
// of the current sensor state.
//
// The sensor will be cleared if:
// (1) the usage is crossing below the low threshold and
// the sensor is currently on; or
// (2) the usage is crossing below the low threshold and
// the sensor will be on (i.e. sensor is currently off
// and has pending trigger requests).
if (is_over_high) {
_pending_clear_count = 0;
}
}
}
if (!has_pending_requests()) {
return;
}
if (pending_clear_count() > 0) {
} else {
}
}
if (_sensor_obj != NULL) {
&args,
CHECK);
}
{
// Holds Service_lock and update the sensor state
_sensor_on = true;
_sensor_count += count;
}
}
if (_sensor_obj != NULL) {
vmSymbols::clear_name(),
&args,
CHECK);
}
{
// Holds Service_lock and update the sensor state
_sensor_on = false;
_pending_clear_count = 0;
}
}
//--------------------------------------------------------------
// Non-product code
#ifndef PRODUCT
}
#endif // PRODUCT