src/share/vm/services/memoryUsage.hpp

Thu, 12 Mar 2009 18:16:36 -0700

author
trims
date
Thu, 12 Mar 2009 18:16:36 -0700
changeset 1063
7bb995fbd3c0
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 2003-2005 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // A memory usage contains the following attributes about memory usage:
duke@435 26 // initSize - represents the initial amount of memory (in bytes) that
duke@435 27 // the Java virtual machine requests from the operating system
duke@435 28 // for memory management. The Java virtual machine may request
duke@435 29 // additional memory from the operating system later when appropriate.
duke@435 30 // Its value may be undefined.
duke@435 31 // used - represents the amount of memory currently used (in bytes).
duke@435 32 // committed - represents the amount of memory (in bytes) that is
duke@435 33 // guaranteed to be available for use by the Java virtual machine.
duke@435 34 // The amount of committed memory may change over time (increase
duke@435 35 // or decrease). It is guaranteed to be greater than or equal
duke@435 36 // to initSize.
duke@435 37 // maxSize - represents the maximum amount of memory (in bytes)
duke@435 38 // that can be used for memory management. The maximum amount of
duke@435 39 // memory for memory management could be less than the amount of
duke@435 40 // committed memory. Its value may be undefined.
duke@435 41
duke@435 42 class MemoryUsage VALUE_OBJ_CLASS_SPEC {
duke@435 43 private:
duke@435 44 size_t _initSize;
duke@435 45 size_t _used;
duke@435 46 size_t _committed;
duke@435 47 size_t _maxSize;
duke@435 48
duke@435 49 public:
duke@435 50 // Constructors
duke@435 51 MemoryUsage(size_t i, size_t u, size_t c, size_t m) :
duke@435 52 _initSize(i), _used(u), _committed(c), _maxSize(m) {};
duke@435 53 MemoryUsage() :
duke@435 54 _initSize(0), _used(0), _committed(0), _maxSize(0) {};
duke@435 55
duke@435 56 size_t init_size() const { return _initSize; }
duke@435 57 size_t used() const { return _used; }
duke@435 58 size_t committed() const { return _committed; }
duke@435 59 size_t max_size() const { return _maxSize; }
duke@435 60
duke@435 61 inline static jlong convert_to_jlong(size_t val) {
duke@435 62 // In the 64-bit vm, a size_t can overflow a jlong (which is signed).
duke@435 63 jlong ret;
duke@435 64 if (val == (size_t)-1) {
duke@435 65 ret = -1L;
duke@435 66 } else {
duke@435 67 NOT_LP64(ret = val;)
duke@435 68 LP64_ONLY(ret = MIN2(val, (size_t)max_jlong);)
duke@435 69 }
duke@435 70 return ret;
duke@435 71 }
duke@435 72
duke@435 73 jlong init_size_as_jlong() const { return convert_to_jlong(_initSize); }
duke@435 74 jlong used_as_jlong() const { return convert_to_jlong(_used); }
duke@435 75 jlong committed_as_jlong() const { return convert_to_jlong(_committed); }
duke@435 76 jlong max_size_as_jlong() const { return convert_to_jlong(_maxSize); }
duke@435 77 };

mercurial