src/share/vm/services/memoryUsage.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/services/memoryUsage.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,77 @@
     1.4 +/*
     1.5 + * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// A memory usage contains the following attributes about memory usage:
    1.29 +//  initSize - represents the initial amount of memory (in bytes) that
    1.30 +//     the Java virtual machine requests from the operating system
    1.31 +//     for memory management.  The Java virtual machine may request
    1.32 +//     additional memory from the operating system later when appropriate.
    1.33 +//     Its value may be undefined.
    1.34 +//  used      - represents the amount of memory currently used (in bytes).
    1.35 +//  committed - represents the amount of memory (in bytes) that is
    1.36 +//     guaranteed to be available for use by the Java virtual machine.
    1.37 +//     The amount of committed memory may change over time (increase
    1.38 +//     or decrease).  It is guaranteed to be greater than or equal
    1.39 +//     to initSize.
    1.40 +//  maxSize   - represents the maximum amount of memory (in bytes)
    1.41 +//     that can be used for memory management. The maximum amount of
    1.42 +//     memory for memory management could be less than the amount of
    1.43 +//     committed memory.  Its value may be undefined.
    1.44 +
    1.45 +class MemoryUsage VALUE_OBJ_CLASS_SPEC {
    1.46 +private:
    1.47 +  size_t _initSize;
    1.48 +  size_t _used;
    1.49 +  size_t _committed;
    1.50 +  size_t _maxSize;
    1.51 +
    1.52 +public:
    1.53 +  // Constructors
    1.54 +  MemoryUsage(size_t i, size_t u, size_t c, size_t m) :
    1.55 +    _initSize(i), _used(u), _committed(c), _maxSize(m) {};
    1.56 +  MemoryUsage() :
    1.57 +    _initSize(0), _used(0), _committed(0), _maxSize(0) {};
    1.58 +
    1.59 +  size_t init_size() const { return _initSize; }
    1.60 +  size_t used()      const { return _used; }
    1.61 +  size_t committed() const { return _committed; }
    1.62 +  size_t max_size()  const { return _maxSize; }
    1.63 +
    1.64 +  inline static jlong convert_to_jlong(size_t val) {
    1.65 +    // In the 64-bit vm, a size_t can overflow a jlong (which is signed).
    1.66 +    jlong ret;
    1.67 +    if (val == (size_t)-1) {
    1.68 +      ret = -1L;
    1.69 +    } else {
    1.70 +      NOT_LP64(ret = val;)
    1.71 +      LP64_ONLY(ret = MIN2(val, (size_t)max_jlong);)
    1.72 +    }
    1.73 +    return ret;
    1.74 +  }
    1.75 +
    1.76 +  jlong init_size_as_jlong() const { return convert_to_jlong(_initSize); }
    1.77 +  jlong used_as_jlong()      const { return convert_to_jlong(_used); }
    1.78 +  jlong committed_as_jlong() const { return convert_to_jlong(_committed); }
    1.79 +  jlong max_size_as_jlong()  const { return convert_to_jlong(_maxSize); }
    1.80 +};

mercurial