java.lang.management
Class MemoryUsage
Retains information on the usage of a particular memory
pool, or heap/non-heap memory as a whole. Memory usage
is represented by four values (all in bytes):
- Initial Level: This is the initial
amount of memory allocated for the pool by the operating
system. This value may be undefined.
- Used Level: This is the amount of
memory currently in use.
- Committed Level: This is the current
amount of memory allocated for the pool by the operating
system. This value will always be equal to or greater than
the current amount of memory in use. It may drop below
the initial amount, if the virtual machine judges this to
be practical.
- Maximum Level: This is the maximum
amount of memory that may be allocated for the pool by
the operating system. Like the initial amount, it may
be undefined. If it is defined, it will be greater than
or equal to the used and committed amounts and may change
over time. It is not guaranteed that the maximum amount
of memory may actually be allocated to the pool. For
example, a request for an amount of memory greater than
the current committed level, but less than the maximum,
may still fail due to resources at the operating system
level not being sufficient to fulfill the demand.
MemoryUsage(long init, long used, long committed, long maximum) - Constructs a new
MemoryUsage object with
the specified allocation levels.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
MemoryUsage
public MemoryUsage(long init,
long used,
long committed,
long maximum)
Constructs a new
MemoryUsage
object with
the specified allocation levels.
init
- the initial amount of memory allocated,
or -1 if this value is undefined. Must
be >= -1.used
- the amount of memory used. Must be >= 0,
and <= committed.committed
- the amount of memory committed for use
at present. Must be >= 0 and <=
maximum (if defined).maximum
- the maximum amount of memory that may be
used, or -1 if this value is undefined.
Must be >= -1.
from
public static MemoryUsage from(CompositeData data)
Returns a
MemoryUsage
instance using the values
given in the supplied
CompositeData
object.
The composite data instance should contain the following
attributes:
All should have the type,
java.lang.Long
.
data
- the composite data structure to take values from.
- a new instance containing the values from the
composite data structure, or
null
if the data structure was also null
.
IllegalArgumentException
- if the composite data structure
does not match the structure
outlined above, or the values
are invalid.
getCommitted
public long getCommitted()
Returns the amount of memory committed for use by this
memory pool (in bytes). This amount is guaranteed to
be available, unlike the maximum.
- the committed amount of memory.
getInit
public long getInit()
Returns the initial amount of memory allocated to the
pool (in bytes). This method may return -1, if the
value is undefined.
- the initial amount of memory allocated, or -1
if this value is undefined.
getMax
public long getMax()
Returns the maximum amount of memory available for this
pool (in bytes). This amount is not guaranteed to
actually be usable. This method may return -1, if the
value is undefined.
- the maximum amount of memory available, or -1
if this value is undefined.
getUsed
public long getUsed()
Returns the amount of memory used (in bytes).
- the amount of used memory.
toString
public String toString()
Returns a
String
representation of
this
MemoryUsage
object. This takes the form
java.lang.management.MemoryUsage[init=i, used=u,
committed=c, maximum=m]
, where
i
is the initial level,
u
is the used level,
c
is the committed level and
m
is the maximum level.
- toString in interface Object
- the string specified above.
MemoryUsage.java - Information on the usage of a memory pool.
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.