Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/memoryUsage.hpp
32285 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_SERVICES_MEMORYUSAGE_HPP25#define SHARE_VM_SERVICES_MEMORYUSAGE_HPP2627#include "utilities/globalDefinitions.hpp"2829// A memory usage contains the following attributes about memory usage:30// initSize - represents the initial amount of memory (in bytes) that31// the Java virtual machine requests from the operating system32// for memory management. The Java virtual machine may request33// additional memory from the operating system later when appropriate.34// Its value may be undefined.35// used - represents the amount of memory currently used (in bytes).36// committed - represents the amount of memory (in bytes) that is37// guaranteed to be available for use by the Java virtual machine.38// The amount of committed memory may change over time (increase39// or decrease). It is guaranteed to be greater than or equal40// to initSize.41// maxSize - represents the maximum amount of memory (in bytes)42// that can be used for memory management. The maximum amount of43// memory for memory management could be less than the amount of44// committed memory. Its value may be undefined.4546class MemoryUsage VALUE_OBJ_CLASS_SPEC {47private:48size_t _initSize;49size_t _used;50size_t _committed;51size_t _maxSize;5253public:54// Constructors55MemoryUsage(size_t i, size_t u, size_t c, size_t m) :56_initSize(i), _used(u), _committed(c), _maxSize(m) {};57MemoryUsage() :58_initSize(0), _used(0), _committed(0), _maxSize(0) {};5960size_t init_size() const { return _initSize; }61size_t used() const { return _used; }62size_t committed() const { return _committed; }63size_t max_size() const { return _maxSize; }6465static size_t undefined_size() { return (size_t) -1; }6667inline static jlong convert_to_jlong(size_t val) {68// In the 64-bit vm, a size_t can overflow a jlong (which is signed).69jlong ret;70if (val == undefined_size()) {71ret = -1L;72} else {73NOT_LP64(ret = val;)74LP64_ONLY(ret = MIN2(val, (size_t)max_jlong);)75}76return ret;77}7879jlong init_size_as_jlong() const { return convert_to_jlong(_initSize); }80jlong used_as_jlong() const { return convert_to_jlong(_used); }81jlong committed_as_jlong() const { return convert_to_jlong(_committed); }82jlong max_size_as_jlong() const { return convert_to_jlong(_maxSize); }83};8485#endif // SHARE_VM_SERVICES_MEMORYUSAGE_HPP868788