src/share/vm/services/memoryUsage.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 5716
73d0d0218068
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_SERVICES_MEMORYUSAGE_HPP
stefank@2314 26 #define SHARE_VM_SERVICES_MEMORYUSAGE_HPP
stefank@2314 27
stefank@2314 28 #include "utilities/globalDefinitions.hpp"
stefank@2314 29
duke@435 30 // A memory usage contains the following attributes about memory usage:
duke@435 31 // initSize - represents the initial amount of memory (in bytes) that
duke@435 32 // the Java virtual machine requests from the operating system
duke@435 33 // for memory management. The Java virtual machine may request
duke@435 34 // additional memory from the operating system later when appropriate.
duke@435 35 // Its value may be undefined.
duke@435 36 // used - represents the amount of memory currently used (in bytes).
duke@435 37 // committed - represents the amount of memory (in bytes) that is
duke@435 38 // guaranteed to be available for use by the Java virtual machine.
duke@435 39 // The amount of committed memory may change over time (increase
duke@435 40 // or decrease). It is guaranteed to be greater than or equal
duke@435 41 // to initSize.
duke@435 42 // maxSize - represents the maximum amount of memory (in bytes)
duke@435 43 // that can be used for memory management. The maximum amount of
duke@435 44 // memory for memory management could be less than the amount of
duke@435 45 // committed memory. Its value may be undefined.
duke@435 46
duke@435 47 class MemoryUsage VALUE_OBJ_CLASS_SPEC {
duke@435 48 private:
duke@435 49 size_t _initSize;
duke@435 50 size_t _used;
duke@435 51 size_t _committed;
duke@435 52 size_t _maxSize;
duke@435 53
duke@435 54 public:
duke@435 55 // Constructors
duke@435 56 MemoryUsage(size_t i, size_t u, size_t c, size_t m) :
duke@435 57 _initSize(i), _used(u), _committed(c), _maxSize(m) {};
duke@435 58 MemoryUsage() :
duke@435 59 _initSize(0), _used(0), _committed(0), _maxSize(0) {};
duke@435 60
duke@435 61 size_t init_size() const { return _initSize; }
duke@435 62 size_t used() const { return _used; }
duke@435 63 size_t committed() const { return _committed; }
duke@435 64 size_t max_size() const { return _maxSize; }
duke@435 65
duke@435 66 inline static jlong convert_to_jlong(size_t val) {
duke@435 67 // In the 64-bit vm, a size_t can overflow a jlong (which is signed).
duke@435 68 jlong ret;
duke@435 69 if (val == (size_t)-1) {
duke@435 70 ret = -1L;
duke@435 71 } else {
duke@435 72 NOT_LP64(ret = val;)
duke@435 73 LP64_ONLY(ret = MIN2(val, (size_t)max_jlong);)
duke@435 74 }
duke@435 75 return ret;
duke@435 76 }
duke@435 77
duke@435 78 jlong init_size_as_jlong() const { return convert_to_jlong(_initSize); }
duke@435 79 jlong used_as_jlong() const { return convert_to_jlong(_used); }
duke@435 80 jlong committed_as_jlong() const { return convert_to_jlong(_committed); }
duke@435 81 jlong max_size_as_jlong() const { return convert_to_jlong(_maxSize); }
duke@435 82 };
stefank@2314 83
stefank@2314 84 #endif // SHARE_VM_SERVICES_MEMORYUSAGE_HPP

mercurial