The attached patch adds the memory bean to our current
roster of management beans.

Changelog:

2006-07-01  Andrew John Hughes  <[EMAIL PROTECTED]>

        * NEWS:
        Updated to include VMMemoryMXBeanImpl.
        * doc/vmintegration.texinfo: Likewise.
        * examples/gnu/classpath/examples/management/TestMemory.java:
        New file.
        * gnu/java/lang/management/ClassLoadingMXBeanImpl.java:
        Remove redundant import.
        * gnu/java/lang/management/MemoryMXBeanImpl.java:
        New file.
        * gnu/java/lang/management/ThreadMXBeanImpl.java:
        Remove redundant import.
        * java/lang/management/ManagementFactory.java:
        (getMemoryMXBean()): Implemented.
        * java/lang/management/MemoryMXBean.java,
        * java/lang/management/MemoryUsage.java:
        New files.
        * java/lang/management/ThreadInfo.java:
        (toString()): Updated documentation.
        * vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java:
        New file.

-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

If you use Microsoft Office, support movement towards the end of vendor lock-in:
http://opendocumentfellowship.org/petition/

"Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn." 
-- Richard Stallman

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.153
diff -u -3 -p -u -r1.153 NEWS
--- NEWS        1 Jul 2006 15:45:24 -0000       1.153
+++ NEWS        2 Jul 2006 17:12:30 -0000
@@ -61,6 +61,10 @@ Runtime interface changes:
   new ThreadInfo class in java.lang.management.  getState() has also
   been added to the VMThread interface; this is required by the bean
   as well as java.lang.Thread.
+* VMMemoryMXBeanImpl is used to implement the low-level support
+  of the memory management bean.  Providing this interface requires
+  providing information about the levels of heap and non-heap memory,
+  and the number of objects eligible for garbage collection.
 
 New in release 0.91 (May 15, 2006)
 
Index: doc/vmintegration.texinfo
===================================================================
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.31
diff -u -3 -p -u -r1.31 vmintegration.texinfo
--- doc/vmintegration.texinfo   1 Jul 2006 15:45:25 -0000       1.31
+++ doc/vmintegration.texinfo   2 Jul 2006 17:12:30 -0000
@@ -1272,6 +1272,7 @@ implementations of the management beans.
 * gnu.java.lang.management.VMRuntimeMXBeanImpl::
 * gnu.java.lang.management.VMClassLoadingMXBeanImpl::
 * gnu.java.lang.management.VMThreadMXBeanImpl::
+* gnu.java.lang.management.VMMemoryMXBeanImpl::
 @end menu
 
 @node 
gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
@@ -1343,7 +1344,7 @@ output is turned or not, respectively.
 verbose class loading output to be turned on and off.
 @end itemize
 
[EMAIL PROTECTED] 
gnu.java.lang.management.VMThreadMXBeanImpl,,gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management
[EMAIL PROTECTED] 
gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management
 @subsection @code{gnu.java.lang.management.VMThreadMXBeanImpl}
 
 The @code{gnu.java.lang.management.ThreadMXBeanImpl} provides an
@@ -1434,6 +1435,39 @@ that have died.  This is specified as a 
 implementation.
 @end itemize
 
[EMAIL PROTECTED] 
gnu.java.lang.management.VMMemoryMXBeanImpl,,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management
[EMAIL PROTECTED] @code{gnu.java.lang.management.VMMemoryMXBeanImpl}
+
+The @code{gnu.java.lang.management.MemoryMXBeanImpl} provides an
+implementation of the @code{java.lang.management.MemoryMXBean} interface,
+and is supported by VM functionality in the form of
[EMAIL PROTECTED]  This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean.  Implementing
+this bean requires the VM to monitor the levels of heap and non-heap
+memory, and provide the number of objects which are eligible for garbage
+collection.
+
+The methods are as follows:
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{(getHeapMemoryUsage())} -- This should return
+an instance of @code{java.lang.management.MemoryUsage} with
+values pertaining to the heap.
[EMAIL PROTECTED] @code{(getNonHeapMemoryUsage())} -- This should return
+an instance of @code{java.lang.management.MemoryUsage} with
+values pertaining to non-heap memory.
[EMAIL PROTECTED] @code{(getObjectPendingFinalizationCount())} -- Returns
+the number of objects which are no longer referenced, and which
+will thus be garbage collected on the next run of the garbage
+collector.
[EMAIL PROTECTED] @code{(isVerbose())} -- This should return @code{true}
+or @code{false}, depending on whether verbose memory management
+output is turned or not, respectively.
[EMAIL PROTECTED] @code{(setVerbose(boolean))} -- This should allow the
+verbose memory management output to be turned on and off.
[EMAIL PROTECTED] itemize
+
 @node Classpath Callbacks, , gnu.java.lang.management, Classpath Hooks
 Some of the classes you implement for the VM will need to call back to
 package-private methods in Classpath:
Index: examples/gnu/classpath/examples/management/TestMemory.java
===================================================================
RCS file: examples/gnu/classpath/examples/management/TestMemory.java
diff -N examples/gnu/classpath/examples/management/TestMemory.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ examples/gnu/classpath/examples/management/TestMemory.java  2 Jul 2006 
17:12:30 -0000
@@ -0,0 +1,52 @@
+/* TestMemory.java -- Tests the memory bean.
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.MemoryMXBean;
+import java.lang.management.ManagementFactory;
+
+public class TestMemory
+{
+  public static void main(String[] args)
+  {
+    MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
+    System.out.println("Bean: " + bean);
+    System.out.println("Heap memory usage: " 
+                      + bean.getHeapMemoryUsage());
+    System.out.println("Non-heap memory usage: " 
+                      + bean.getNonHeapMemoryUsage());
+    System.out.println("Objects pending finalization: " 
+                      + bean.getObjectPendingFinalizationCount());
+    System.out.println("Running garbage collector via bean...");
+    bean.gc();
+    System.out.println("Heap memory usage: " 
+                      + bean.getHeapMemoryUsage());
+    System.out.println("Non-heap memory usage: " 
+                      + bean.getNonHeapMemoryUsage());
+    System.out.println("Objects pending finalization: " 
+                      + bean.getObjectPendingFinalizationCount());
+    boolean verbosity = bean.isVerbose();
+    System.out.println("Verbose memory output: " + (verbosity ? "yes" : "no"));
+    System.out.println("Changing verbose setting...");
+    bean.setVerbose(!verbosity);
+    System.out.println("Verbose memory output: " + (bean.isVerbose() ? "yes" : 
"no"));
+  }
+}
Index: gnu/java/lang/management/ClassLoadingMXBeanImpl.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java,v
retrieving revision 1.3
diff -u -3 -p -u -r1.3 ClassLoadingMXBeanImpl.java
--- gnu/java/lang/management/ClassLoadingMXBeanImpl.java        1 Jul 2006 
11:37:59 -0000       1.3
+++ gnu/java/lang/management/ClassLoadingMXBeanImpl.java        2 Jul 2006 
17:12:30 -0000
@@ -38,7 +38,6 @@ exception statement from your version. *
 package gnu.java.lang.management;
 
 import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.ManagementPermission;
 
 /**
  * Provides access to information about the class loading 
Index: gnu/java/lang/management/MemoryMXBeanImpl.java
===================================================================
RCS file: gnu/java/lang/management/MemoryMXBeanImpl.java
diff -N gnu/java/lang/management/MemoryMXBeanImpl.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/java/lang/management/MemoryMXBeanImpl.java      2 Jul 2006 17:12:30 
-0000
@@ -0,0 +1,88 @@
+/* MemoryMXBeanImpl.java - Implementation of a memory bean
+   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. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory 
+ * management of the current invocation of the virtual
+ * machine.  Instances of this bean are obtained by calling
+ * [EMAIL PROTECTED] ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public final class MemoryMXBeanImpl
+  extends BeanImpl
+  implements MemoryMXBean
+{
+
+  public void gc()
+  {
+    System.gc();
+  }
+
+  public MemoryUsage getHeapMemoryUsage()
+  {
+    return VMMemoryMXBeanImpl.getHeapMemoryUsage();
+  }
+
+  public MemoryUsage getNonHeapMemoryUsage()
+  {
+    return VMMemoryMXBeanImpl.getNonHeapMemoryUsage();
+  }
+
+  public int getObjectPendingFinalizationCount()
+  {
+    return VMMemoryMXBeanImpl.getObjectPendingFinalizationCount();
+  }
+
+  public boolean isVerbose()
+  {
+    return VMMemoryMXBeanImpl.isVerbose();
+  }
+
+  public void setVerbose(boolean verbose)
+  {
+    checkControlPermissions();
+    VMMemoryMXBeanImpl.setVerbose(verbose);
+  }
+
+}
Index: gnu/java/lang/management/ThreadMXBeanImpl.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/lang/management/ThreadMXBeanImpl.java,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 ThreadMXBeanImpl.java
--- gnu/java/lang/management/ThreadMXBeanImpl.java      1 Jul 2006 11:37:59 
-0000       1.1
+++ gnu/java/lang/management/ThreadMXBeanImpl.java      2 Jul 2006 17:12:30 
-0000
@@ -41,7 +41,6 @@ import gnu.classpath.SystemProperties;
 
 import java.lang.management.ThreadInfo;
 import java.lang.management.ThreadMXBean;
-import java.lang.management.ManagementPermission;
 
 /**
  * Provides access to information about the threads 
Index: java/lang/management/ManagementFactory.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/lang/management/ManagementFactory.java,v
retrieving revision 1.6
diff -u -3 -p -u -r1.6 ManagementFactory.java
--- java/lang/management/ManagementFactory.java 1 Jul 2006 11:37:59 -0000       
1.6
+++ java/lang/management/ManagementFactory.java 2 Jul 2006 17:12:31 -0000
@@ -39,6 +39,7 @@ package java.lang.management;
 
 import gnu.java.lang.management.ClassLoadingMXBeanImpl;
 import gnu.java.lang.management.OperatingSystemMXBeanImpl;
+import gnu.java.lang.management.MemoryMXBeanImpl;
 import gnu.java.lang.management.RuntimeMXBeanImpl;
 import gnu.java.lang.management.ThreadMXBeanImpl;
 
@@ -83,6 +84,11 @@ public class ManagementFactory
   private static ThreadMXBean threadBean;
 
   /**
+   * The memory bean.
+   */
+  private static MemoryMXBean memoryBean;
+
+  /**
    * Private constructor to prevent instance creation.
    */
   private ManagementFactory() {}
@@ -143,4 +149,18 @@ public class ManagementFactory
     return threadBean;
   }
 
+  /**
+   * Returns the memory management bean for the running
+   * virtual machine.
+   *
+   * @return an instance of [EMAIL PROTECTED] MemoryMXBean} for
+   *         this virtual machine.
+   */
+  public static MemoryMXBean getMemoryMXBean()
+  {
+    if (memoryBean == null)
+      memoryBean = new MemoryMXBeanImpl();
+    return memoryBean;
+  }
+
 }
Index: java/lang/management/MemoryMXBean.java
===================================================================
RCS file: java/lang/management/MemoryMXBean.java
diff -N java/lang/management/MemoryMXBean.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/management/MemoryMXBean.java      2 Jul 2006 17:12:31 -0000
@@ -0,0 +1,144 @@
+/* MemoryMXBean.java - Interface for a memory bean
+   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. */
+
+package java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about the memory used 
+ * by the virtual machine.  An instance of this bean is
+ * obtained by calling
+ * [EMAIL PROTECTED] ManagementFactory#getMemoryMXBean()}.
+ * </p>
+ * <p>
+ * The Java virtual machine uses two types of memory:
+ * heap memory and non-heap memory.  The heap is the
+ * storage location for class and array instances, and is
+ * thus the main source of memory associated with running
+ * Java programs.  The heap is created when the virtual
+ * machine is started, and is periodically scanned by the
+ * garbage collector(s), in order to reclaim memory which
+ * is no longer used (e.g. because an object reference has
+ * gone out of scope).
+ * </p>
+ * <p>
+ * Non-heap memory is used by the virtual machine in order to
+ * perform its duties.  Thus, it mainly acts as the storage
+ * location for structures created as a result of parsing Java
+ * bytecode, such as the constant pool and constructor/method
+ * declarations.  When a Just-In-Time (JIT) compiler is in
+ * operation, this will use non-heap memory to store compiled
+ * bytecode.
+ * </p>
+ * <p>
+ * Both types of memory may be non-contiguous.  During the
+ * lifetime of the virtual machine, the size of both may
+ * either change (either expanding or contracting) or stay
+ * the same.
+ * </p>
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public interface MemoryMXBean
+{
+  
+  /**
+   * Instigates a garbage collection cycle.  The virtual
+   * machine's garbage collector should make the best
+   * attempt it can at reclaiming unused memory.  This
+   * is equivalent to invoking [EMAIL PROTECTED] java.lang.System.gc()}.
+   *
+   * @see java.lang.System#gc()
+   */
+  void gc();
+
+  /**
+   * Returns a [EMAIL PROTECTED] MemoryUsage} object representing the
+   * current state of the heap.  This incorporates various
+   * statistics on both the initial and current memory
+   * allocations used by the heap.
+   *
+   * @return a [EMAIL PROTECTED] MemoryUsage} object for the heap.
+   */
+  MemoryUsage getHeapMemoryUsage();
+
+  /**
+   * Returns a [EMAIL PROTECTED] MemoryUsage} object representing the
+   * current state of non-heap memory.  This incorporates
+   * various statistics on both the initial and current
+   * memory allocations used by non-heap memory..
+   *
+   * @return a [EMAIL PROTECTED] MemoryUsage} object for non-heap
+   *         memory.
+   */
+  MemoryUsage getNonHeapMemoryUsage();
+  
+  /**
+   * Returns the number of objects which are waiting to
+   * be garbage collected (finalized).  An object is
+   * finalized when the garbage collector determines that
+   * there are no more references to that object are in
+   * use.
+   *
+   * @return the number of objects awaiting finalization.
+   */
+  int getObjectPendingFinalizationCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when memory is allocated and deallocated.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose memory output is on.
+   */
+  boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when memory is allocated and deallocated.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose memory output.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   */
+  void setVerbose(boolean verbose);
+
+}
Index: java/lang/management/MemoryUsage.java
===================================================================
RCS file: java/lang/management/MemoryUsage.java
diff -N java/lang/management/MemoryUsage.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/management/MemoryUsage.java       2 Jul 2006 17:12:31 -0000
@@ -0,0 +1,220 @@
+/* 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. */
+
+package java.lang.management;
+
+/**
+ * <p>
+ * 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):
+ * </p>
+ * <ul>
+ * <li><strong>Initial Level</strong>: This is the initial
+ * amount of memory allocated for the pool by the operating
+ * system.  This value may be undefined.</li>
+ * <li><strong>Used Level</strong>: This is the amount of
+ * memory currently in use.</li>
+ * <li><strong>Committed Level</strong>: 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.</li>
+ * <li><strong>Maximum Level</strong>: 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.</li>
+ * </ul>
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ * @see MemoryMXBean
+ * @see MemoryPoolMXBean
+ */
+public class MemoryUsage
+{
+
+  /**
+   * The initial amount of memory allocated.
+   */
+  private long init;
+
+  /**
+   * The amount of memory used.
+   */
+  private long used;
+
+  /**
+   * The amount of memory committed for use.
+   */
+  private long committed;
+
+  /**
+   * The maximum amount of memory available.
+   */
+  private long maximum;
+
+  /**
+   * Constructs a new [EMAIL PROTECTED] MemoryUsage} object with
+   * the specified allocation levels.
+   *
+   * @param init the initial amount of memory allocated,
+   *             or -1 if this value is undefined.  Must
+   *             be >= -1.
+   * @param used the amount of memory used.  Must be >= 0,
+   *             and <= committed.
+   * @param committed the amount of memory committed for use
+   *                  at present.  Must be >= 0 and <=
+   *                  maximum (if defined).
+   * @param maximum the maximum amount of memory that may be
+   *                used, or -1 if this value is undefined.
+   *                Must be >= -1.
+   * @throws IllegalArgumentException if the values break any
+   *                                  of the limits specified
+   *                                  above.
+   */
+  public MemoryUsage(long init, long used, long committed,
+                    long maximum)
+  {
+    if (init < -1)
+      throw new IllegalArgumentException("Initial value of "
+                                        + init + " is too small.");
+    if (used < 0)
+      throw new IllegalArgumentException("Used value of "
+                                        + used + " is too small.");
+    if (committed < 0)
+      throw new IllegalArgumentException("Committed value of "
+                                        + committed + " is too small.");
+    if (committed < used)
+      throw new IllegalArgumentException("Committed value of "
+                                        + committed + " is below "
+                                        + used + ", the amount used.");
+    if (maximum < -1)
+      throw new IllegalArgumentException("Maximum value of "
+                                        + maximum + " is too small.");
+    if (maximum != -1 && maximum < committed)
+      throw new IllegalArgumentException("Maximum value of " 
+                                        + maximum + " is below "
+                                        + committed + ", the amount "
+                                        + "committed.");
+    this.init = init;
+    this.used = used;
+    this.committed = committed;
+    this.maximum = maximum;
+  }
+
+  /**
+   * Returns the amount of memory committed for use by this
+   * memory pool (in bytes).  This amount is guaranteed to
+   * be available, unlike the maximum.
+   *
+   * @return the committed amount of memory.
+   */
+  public long getCommitted()
+  {
+    return committed;
+  }
+
+  /**
+   * Returns the initial amount of memory allocated to the
+   * pool (in bytes).  This method may return -1, if the
+   * value is undefined.
+   *
+   * @return the initial amount of memory allocated, or -1
+   *         if this value is undefined.
+   */
+  public long getInit()
+  {
+    return init;
+  }
+
+  /**
+   * 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.
+   *
+   * @return the maximum amount of memory available, or -1
+   *         if this value is undefined.
+   */
+  public long getMax()
+  {
+    return maximum;
+  }
+
+  /**
+   * Returns the amount of memory used (in bytes).
+   *
+   * @return the amount of used memory.
+   */
+  public long getUsed()
+  {
+    return used;
+  }
+
+  /**
+   * Returns a [EMAIL PROTECTED] java.lang.String} representation of
+   * this [EMAIL PROTECTED] MemoryUsage} object.  This takes the form
+   * <code>java.lang.management.MemoryUsage[init=i, used=u,
+   * committed=c, maximum=m]</code>, where <code>i</code>
+   * is the initial level, <code>u</code> is the used level,
+   * <code>c</code> is the committed level and <code>m</code>
+   * is the maximum level.
+   *
+   * @return the string specified above.
+   */
+  public String toString()
+  {
+    int megabyte = 1024 * 1024;
+    return getClass().getName() +
+      "[init=" + init + " bytes (~" + (init / megabyte) +
+      "MB), used=" + used + " bytes (~" + (used / megabyte) +
+      "MB), committed=" + committed + " bytes (~" + (committed / megabyte) +
+      "MB), maximum=" + maximum + " bytes (~" + (maximum / megabyte) +
+      "]";
+  }
+
+}
+  
Index: java/lang/management/ThreadInfo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/management/ThreadInfo.java,v
retrieving revision 1.2
diff -u -3 -p -u -r1.2 ThreadInfo.java
--- java/lang/management/ThreadInfo.java        1 Jul 2006 11:37:59 -0000       
1.2
+++ java/lang/management/ThreadInfo.java        2 Jul 2006 17:12:31 -0000
@@ -461,10 +461,20 @@ public class ThreadInfo
   /**
    * Returns a [EMAIL PROTECTED] java.lang.String} representation of
    * this [EMAIL PROTECTED] ThreadInfo} object.  This takes the form
-   * <code>java.lang.ThreadInfo[id=tid, maxDepth=md]</code>,
-   * where <code>tid</code> is the thread identifier
-   * and <code>md</code> is the maximum depth used by
-   * this [EMAIL PROTECTED] ThreadInfo}.
+   * <code>java.lang.management.ThreadInfo[id=tid, name=n,
+   * state=s, blockedCount=bc, waitedCount=wc, isInNative=iin,
+   * isSuspended=is]</code>, where <code>tid</code> is
+   * the thread identifier, <code>n</code> is the
+   * thread name, <code>s</code> is the thread state,
+   * <code>bc</code> is the blocked state count,
+   * <code>wc</code> is the waiting state count and
+   * <code>iin</code> and <code>is</code> are boolean
+   * flags to indicate the thread is in native code or
+   * suspended respectively.  If the thread is blocked,
+   * <code>lock=l, lockOwner=lo</code> is also included,
+   * where <code>l</code> is the lock waited for, and
+   * <code>lo</code> is the thread which owns the lock
+   * (or null if there is no owner).
    *
    * @return the string specified above.
    */
Index: vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
===================================================================
RCS file: vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
diff -N vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java       2 Jul 
2006 17:12:32 -0000
@@ -0,0 +1,102 @@
+/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
+   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. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine.  Instances of this bean are obtained by calling
+ * [EMAIL PROTECTED] ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+final class VMMemoryMXBeanImpl
+{
+
+  /**
+   * Returns an instance of [EMAIL PROTECTED] java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for the heap.
+   *
+   * @return an [EMAIL PROTECTED] java.lang.management.MemoryUsage} instance
+   *         for the heap.
+   */
+  static native MemoryUsage getHeapMemoryUsage();
+
+  /**
+   * Returns an instance of [EMAIL PROTECTED] java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for non-heap memory.
+   *
+   * @return an [EMAIL PROTECTED] java.lang.management.MemoryUsage} instance
+   *         for non-heap memory.
+   */
+  static native MemoryUsage getNonHeapMemoryUsage();
+
+  /**
+   * Returns the number of objects ready to be garbage collected.
+   *
+   * @return the number of finalizable objects.
+   */
+  static native int getObjectPendingFinalizationCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when memory is allocated and deallocated.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose class loading output is on.
+   */
+  static native boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when memory is allocated and deallocated.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose class loading
+   *                output.
+   */
+  static native void setVerbose(boolean verbose);
+
+}

Attachment: signature.asc
Description: Digital signature

Reply via email to