src/share/vm/services/memoryUsage.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/services/memoryUsage.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,86 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_SERVICES_MEMORYUSAGE_HPP
    1.29 +#define SHARE_VM_SERVICES_MEMORYUSAGE_HPP
    1.30 +
    1.31 +#include "utilities/globalDefinitions.hpp"
    1.32 +
    1.33 +// A memory usage contains the following attributes about memory usage:
    1.34 +//  initSize - represents the initial amount of memory (in bytes) that
    1.35 +//     the Java virtual machine requests from the operating system
    1.36 +//     for memory management.  The Java virtual machine may request
    1.37 +//     additional memory from the operating system later when appropriate.
    1.38 +//     Its value may be undefined.
    1.39 +//  used      - represents the amount of memory currently used (in bytes).
    1.40 +//  committed - represents the amount of memory (in bytes) that is
    1.41 +//     guaranteed to be available for use by the Java virtual machine.
    1.42 +//     The amount of committed memory may change over time (increase
    1.43 +//     or decrease).  It is guaranteed to be greater than or equal
    1.44 +//     to initSize.
    1.45 +//  maxSize   - represents the maximum amount of memory (in bytes)
    1.46 +//     that can be used for memory management. The maximum amount of
    1.47 +//     memory for memory management could be less than the amount of
    1.48 +//     committed memory.  Its value may be undefined.
    1.49 +
    1.50 +class MemoryUsage VALUE_OBJ_CLASS_SPEC {
    1.51 +private:
    1.52 +  size_t _initSize;
    1.53 +  size_t _used;
    1.54 +  size_t _committed;
    1.55 +  size_t _maxSize;
    1.56 +
    1.57 +public:
    1.58 +  // Constructors
    1.59 +  MemoryUsage(size_t i, size_t u, size_t c, size_t m) :
    1.60 +    _initSize(i), _used(u), _committed(c), _maxSize(m) {};
    1.61 +  MemoryUsage() :
    1.62 +    _initSize(0), _used(0), _committed(0), _maxSize(0) {};
    1.63 +
    1.64 +  size_t init_size() const { return _initSize; }
    1.65 +  size_t used()      const { return _used; }
    1.66 +  size_t committed() const { return _committed; }
    1.67 +  size_t max_size()  const { return _maxSize; }
    1.68 +
    1.69 +  static size_t undefined_size() { return (size_t) -1; }
    1.70 +
    1.71 +  inline static jlong convert_to_jlong(size_t val) {
    1.72 +    // In the 64-bit vm, a size_t can overflow a jlong (which is signed).
    1.73 +    jlong ret;
    1.74 +    if (val == undefined_size()) {
    1.75 +      ret = -1L;
    1.76 +    } else {
    1.77 +      NOT_LP64(ret = val;)
    1.78 +      LP64_ONLY(ret = MIN2(val, (size_t)max_jlong);)
    1.79 +    }
    1.80 +    return ret;
    1.81 +  }
    1.82 +
    1.83 +  jlong init_size_as_jlong() const { return convert_to_jlong(_initSize); }
    1.84 +  jlong used_as_jlong()      const { return convert_to_jlong(_used); }
    1.85 +  jlong committed_as_jlong() const { return convert_to_jlong(_committed); }
    1.86 +  jlong max_size_as_jlong()  const { return convert_to_jlong(_maxSize); }
    1.87 +};
    1.88 +
    1.89 +#endif // SHARE_VM_SERVICES_MEMORYUSAGE_HPP

mercurial