You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Vamsavardhana Reddy <c1...@gmail.com> on 2007/12/03 19:52:05 UTC

How to get memory statistics from a remote Geronimo runtime?

I am wondering if the following (which works) is the correct way to get
maxHeapSize and usedMemory from a remote Geronimo server.

import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;

        Map map = new HashMap();
        map.put("jmx.remote.credentials", new String[] {user, password});
        JMXServiceURL address = new JMXServiceURL(
                "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port +
"/JMXConnector");
        JMXConnector jmxConnector = JMXConnectorFactory.connect(address,
map);
        mbServerConnection = jmxConnector.getMBeanServerConnection();
        objName = ObjectName.getInstance
("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
        Stats stats = (Stats) mbServerConnection.getAttribute(objName,
"stats");
         BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl)
stats.getStatistic("HeapSize");
        long maxMemory = statistic.getUpperBound();
        long usedMemory = statistic.getCurrent();

Is this ok?  Or, is there a better way?

++Vamsi

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
That worked too.  Thanks.

++Vamsi

On Dec 4, 2007 12:29 AM, Viet Nguyen <vh...@gmail.com> wrote:

> You can do it that way or do it the JSR-77 way.
>
>            Properties props = new Properties();
>            props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.RemoteInitialContextFactory");
>            props.setProperty(Context.PROVIDER_URL,
> "ejbd://localhost:4201");
>            props.setProperty(Context.SECURITY_PRINCIPAL, username);
>            props.setProperty(Context.SECURITY_CREDENTIALS, password);
>            props.setProperty("openejb.authentication.realmName",
> "geronimo-admin");
>            InitialContext ctx = new InitialContext(p);
>
>            ManagementHome mejbHome =
> (ManagementHome)ctx.lookup("ejb/mgmt/MEJBRemoteHome");
>            mejb = mejbHome.create();
>            Stats stats = (Stats)mejb.getAttribute(new
> ObjectName(<mbean_name_here>), "stats");
>
> Hope this helps,
> Viet Nguyen
>
> On Dec 3, 2007 1:52 PM, Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > I am wondering if the following (which works) is the correct way to get
> > maxHeapSize and usedMemory from a remote Geronimo server.
> >
> > import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> >
> >         Map map = new HashMap();
> >         map.put("jmx.remote.credentials", new String[] {user,
> password});
> >         JMXServiceURL address = new JMXServiceURL(
> >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port +
> > "/JMXConnector");
> >         JMXConnector jmxConnector = JMXConnectorFactory.connect(address,
> > map);
> >         mbServerConnection = jmxConnector.getMBeanServerConnection();
> >         objName =
> > ObjectName.getInstance
> ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> >         Stats stats = (Stats) mbServerConnection.getAttribute(objName,
> > "stats");
> >          BoundedRangeStatisticImpl statistic =
> (BoundedRangeStatisticImpl)
> > stats.getStatistic("HeapSize");
> >         long maxMemory = statistic.getUpperBound();
> >         long usedMemory = statistic.getCurrent();
> >
> > Is this ok?  Or, is there a better way?
> >
> > ++Vamsi
> >
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Viet Nguyen <vh...@gmail.com>.
You can do it that way or do it the JSR-77 way.

            Properties props = new Properties();
            props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
            props.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
            props.setProperty(Context.SECURITY_PRINCIPAL, username);
            props.setProperty(Context.SECURITY_CREDENTIALS, password);
            props.setProperty("openejb.authentication.realmName",
"geronimo-admin");
            InitialContext ctx = new InitialContext(p);

            ManagementHome mejbHome =
(ManagementHome)ctx.lookup("ejb/mgmt/MEJBRemoteHome");
            mejb = mejbHome.create();
            Stats stats = (Stats)mejb.getAttribute(new
ObjectName(<mbean_name_here>), "stats");

Hope this helps,
Viet Nguyen

On Dec 3, 2007 1:52 PM, Vamsavardhana Reddy <c1...@gmail.com> wrote:
> I am wondering if the following (which works) is the correct way to get
> maxHeapSize and usedMemory from a remote Geronimo server.
>
> import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
>
>         Map map = new HashMap();
>         map.put("jmx.remote.credentials", new String[] {user, password});
>         JMXServiceURL address = new JMXServiceURL(
>                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port +
> "/JMXConnector");
>         JMXConnector jmxConnector = JMXConnectorFactory.connect(address,
> map);
>         mbServerConnection = jmxConnector.getMBeanServerConnection();
>         objName =
> ObjectName.getInstance("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
>         Stats stats = (Stats) mbServerConnection.getAttribute(objName,
> "stats");
>          BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl)
> stats.getStatistic("HeapSize");
>         long maxMemory = statistic.getUpperBound();
>         long usedMemory = statistic.getCurrent();
>
> Is this ok?  Or, is there a better way?
>
> ++Vamsi
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
On Dec 4, 2007 11:23 PM, Anita Kulshreshtha <a_...@yahoo.com> wrote:

>   It is not clear to me if this is part of the earlier code or a
> separate program. If it is part of the JMX code, then Runtime is from
> the local jvm not remote. The non heap Memory for this program in
> either case is negligible.

I got the code to run in a jsp.  So, the statistics it shows are indeed from
Geronimo's JVM.



>
>   You could start G with -Dcom.sun.management.jmxremote. Start
> jconsole and click on the Memory tab to get the whole picture.

Will try this.  Thank you.


>
>   Hope this is helpful
>
> Thanks
> Anita
>
> --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
>
> > I don't know why the non heap memory is missing in the equations.
> > The
> > equations I gave are based what I observed by running the following
> > code.
> >
> >             MemoryMXBean memmxbean =
> > ManagementFactory.getMemoryMXBean();
> >             Runtime rt = Runtime.getRuntime();
> >             MemoryUsage memUsage = memmxbean.getHeapMemoryUsage();
> >             System.err.println("init="+memUsage.getInit());
> >             System.err.println("max="+memUsage.getMax());
> >             System.err.println("used="+memUsage.getUsed());
> >             System.err.println("committed="+memUsage.getCommitted());
> >             System.err.println("free="+(memUsage.getCommitted()-
> > memUsage.getUsed()));
> >             System.err.println("TotalMemory = "+rt.totalMemory());
> >             System.err.println("MaxMemory = "+rt.maxMemory());
> >             System.err.println("FreeMemory = "+rt.freeMemory());
> >
> > System.err.println("Used="+(rt.totalMemory()-rt.freeMemory()));
> >
> > ++Vamsi
> >
> > On Dec 4, 2007 8:57 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > wrote:
> >
> > >   IIUC,
> > >
> > >
> >
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html
> > >   runtime values are sum of values from Heap and non heap memory.
> > In
> > > other words you need to add contribution from non heap Memory to
> > all 4
> > > equations.
> > >
> > > Thanks
> > > Anita
> > >
> > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > >
> > > > I don't know if it is necessary to add the statistics from
> > Runtime.
> > > > Here is
> > > > the relationship I see between the stats from Runtime and those
> > got
> > > > from
> > > > MemoryMXBean.getHeapMemoryUsage()
> > > >
> > > > Runtime.totalMemory() == MemoryUsage.getCommitted()
> > > > Runtime.maxMemory() == MemoryUsage.getMax()
> > > > Runtime.freeMemory() == MemoryUsage.getCommitted() -
> > > > MemoryUsage.getUsed()
> > > > Runtime.totalMemory() - Runtime.freeMemory() ==
> > MemoryUsage.getUsed()
> > > >
> > > > ++Vamsi
> > > >
> > > >
> > > > On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > > > wrote:
> > > >
> > > > >   If you are interested in usedMemory and maxMemory as given by
> > > > > Runtime, we could add that again. The JVM Stats give a rough
> > > > estimate
> > > > > of heap memory only.
> > > > >
> > > > > Thanks
> > > > > Anita
> > > > >
> > > > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > > > >
> > > > > > I am wondering if the following (which works) is the correct
> > way
> > > > to
> > > > > > get
> > > > > > maxHeapSize and usedMemory from a remote Geronimo server.
> > > > > >
> > > > > > import
> > > > > >
> > org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> > > > > >
> > > > > >         Map map = new HashMap();
> > > > > >         map.put("jmx.remote.credentials", new String[] {user,
> > > > > > password});
> > > > > >         JMXServiceURL address = new JMXServiceURL(
> > > > > >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" +
> > port
> > > > +
> > > > > > "/JMXConnector");
> > > > > >         JMXConnector jmxConnector =
> > > > > > JMXConnectorFactory.connect(address,
> > > > > > map);
> > > > > >         mbServerConnection =
> > > > jmxConnector.getMBeanServerConnection();
> > > > > >         objName = ObjectName.getInstance
> > > > > > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> > > > > >         Stats stats = (Stats)
> > > > > > mbServerConnection.getAttribute(objName,
> > > > > > "stats");
> > > > > >          BoundedRangeStatisticImpl statistic =
> > > > > > (BoundedRangeStatisticImpl)
> > > > > > stats.getStatistic("HeapSize");
> > > > > >         long maxMemory = statistic.getUpperBound();
> > > > > >         long usedMemory = statistic.getCurrent();
> > > > > >
> > > > > > Is this ok?  Or, is there a better way?
> > > > > >
> > > > > > ++Vamsi
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
> ____________________________________________________________________________________
> > > > > Be a better pen pal.
> > > > > Text or chat with friends inside Yahoo! Mail. See how.
> > > > > http://overview.mail.yahoo.com/
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
> ____________________________________________________________________________________
> > > Be a better sports nut!  Let your teams follow you
> > > with Yahoo Mobile. Try it now.
> > > http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> > >
> >
>
>
>
>
>  ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
On Dec 7, 2007 9:38 PM, Matt Hogstrom <ma...@hogstrom.org> wrote:

>
> On Dec 5, 2007, at 4:29 AM, Vamsavardhana Reddy wrote:
>
> >
> >
> > On Dec 4, 2007 11:23 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > wrote:
> >   It is not clear to me if this is part of the earlier code or a
> > separate program. If it is part of the JMX code, then Runtime is from
> > the local jvm not remote. The non heap Memory for this program in
> > either case is negligible.
> >   You could start G with -Dcom.sun.management.jmxremote. Start
> > jconsole and click on the Memory tab to get the whole picture.
> > I have started G with the said option and hooked up jconsole.  The
> > HeapMemoryUsage is showing exactly what Runtime is returning.
> >
> > It is only the heap memory exhaustion that results in OOME.  I guess
> > I am ok for now as this is what I am interested in.
> >
>
> One will get OOM Exceptions if there is insufficient native memory to
> satisfy a Java request.  For instance, when creating a thread, the OS
> has to allocate some native memory to create the Java Object. If that
> native allocation fails you will get an OOM even though you have
> plenty of heap memory.

You are right.  Any ideas on how to figure if we are exhausting that native
memory?

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Matt Hogstrom <ma...@hogstrom.org>.
On Dec 5, 2007, at 4:29 AM, Vamsavardhana Reddy wrote:

>
>
> On Dec 4, 2007 11:23 PM, Anita Kulshreshtha <a_...@yahoo.com>  
> wrote:
>   It is not clear to me if this is part of the earlier code or a
> separate program. If it is part of the JMX code, then Runtime is from
> the local jvm not remote. The non heap Memory for this program in
> either case is negligible.
>   You could start G with -Dcom.sun.management.jmxremote. Start
> jconsole and click on the Memory tab to get the whole picture.
> I have started G with the said option and hooked up jconsole.  The  
> HeapMemoryUsage is showing exactly what Runtime is returning.
>
> It is only the heap memory exhaustion that results in OOME.  I guess  
> I am ok for now as this is what I am interested in.
>

One will get OOM Exceptions if there is insufficient native memory to  
satisfy a Java request.  For instance, when creating a thread, the OS  
has to allocate some native memory to create the Java Object. If that  
native allocation fails you will get an OOM even though you have  
plenty of heap memory.

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
On Dec 4, 2007 11:23 PM, Anita Kulshreshtha <a_...@yahoo.com> wrote:

>   It is not clear to me if this is part of the earlier code or a
> separate program. If it is part of the JMX code, then Runtime is from
> the local jvm not remote. The non heap Memory for this program in
> either case is negligible.
>   You could start G with -Dcom.sun.management.jmxremote. Start
> jconsole and click on the Memory tab to get the whole picture.

I have started G with the said option and hooked up jconsole.  The
HeapMemoryUsage is showing exactly what Runtime is returning.

It is only the heap memory exhaustion that results in OOME.  I guess I am ok
for now as this is what I am interested in.


>   Hope this is helpful
>
> Thanks
> Anita
>
> --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
>
> > I don't know why the non heap memory is missing in the equations.
> > The
> > equations I gave are based what I observed by running the following
> > code.
> >
> >             MemoryMXBean memmxbean =
> > ManagementFactory.getMemoryMXBean();
> >             Runtime rt = Runtime.getRuntime();
> >             MemoryUsage memUsage = memmxbean.getHeapMemoryUsage();
> >             System.err.println("init="+memUsage.getInit());
> >             System.err.println("max="+memUsage.getMax());
> >             System.err.println("used="+memUsage.getUsed());
> >             System.err.println("committed="+memUsage.getCommitted());
> >             System.err.println("free="+(memUsage.getCommitted()-
> > memUsage.getUsed()));
> >             System.err.println("TotalMemory = "+rt.totalMemory());
> >             System.err.println("MaxMemory = "+rt.maxMemory());
> >             System.err.println("FreeMemory = "+rt.freeMemory());
> >
> > System.err.println("Used="+(rt.totalMemory()-rt.freeMemory()));
> >
> > ++Vamsi
> >
> > On Dec 4, 2007 8:57 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > wrote:
> >
> > >   IIUC,
> > >
> > >
> >
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html
> > >   runtime values are sum of values from Heap and non heap memory.
> > In
> > > other words you need to add contribution from non heap Memory to
> > all 4
> > > equations.
> > >
> > > Thanks
> > > Anita
> > >
> > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > >
> > > > I don't know if it is necessary to add the statistics from
> > Runtime.
> > > > Here is
> > > > the relationship I see between the stats from Runtime and those
> > got
> > > > from
> > > > MemoryMXBean.getHeapMemoryUsage()
> > > >
> > > > Runtime.totalMemory() == MemoryUsage.getCommitted()
> > > > Runtime.maxMemory() == MemoryUsage.getMax()
> > > > Runtime.freeMemory() == MemoryUsage.getCommitted() -
> > > > MemoryUsage.getUsed()
> > > > Runtime.totalMemory() - Runtime.freeMemory() ==
> > MemoryUsage.getUsed()
> > > >
> > > > ++Vamsi
> > > >
> > > >
> > > > On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > > > wrote:
> > > >
> > > > >   If you are interested in usedMemory and maxMemory as given by
> > > > > Runtime, we could add that again. The JVM Stats give a rough
> > > > estimate
> > > > > of heap memory only.
> > > > >
> > > > > Thanks
> > > > > Anita
> > > > >
> > > > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > > > >
> > > > > > I am wondering if the following (which works) is the correct
> > way
> > > > to
> > > > > > get
> > > > > > maxHeapSize and usedMemory from a remote Geronimo server.
> > > > > >
> > > > > > import
> > > > > >
> > org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> > > > > >
> > > > > >         Map map = new HashMap();
> > > > > >         map.put("jmx.remote.credentials", new String[] {user,
> > > > > > password});
> > > > > >         JMXServiceURL address = new JMXServiceURL(
> > > > > >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" +
> > port
> > > > +
> > > > > > "/JMXConnector");
> > > > > >         JMXConnector jmxConnector =
> > > > > > JMXConnectorFactory.connect(address,
> > > > > > map);
> > > > > >         mbServerConnection =
> > > > jmxConnector.getMBeanServerConnection();
> > > > > >         objName = ObjectName.getInstance
> > > > > > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> > > > > >         Stats stats = (Stats)
> > > > > > mbServerConnection.getAttribute(objName,
> > > > > > "stats");
> > > > > >          BoundedRangeStatisticImpl statistic =
> > > > > > (BoundedRangeStatisticImpl)
> > > > > > stats.getStatistic("HeapSize");
> > > > > >         long maxMemory = statistic.getUpperBound();
> > > > > >         long usedMemory = statistic.getCurrent();
> > > > > >
> > > > > > Is this ok?  Or, is there a better way?
> > > > > >
> > > > > > ++Vamsi
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
> ____________________________________________________________________________________
> > > > > Be a better pen pal.
> > > > > Text or chat with friends inside Yahoo! Mail. See how.
> > > > > http://overview.mail.yahoo.com/
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
> ____________________________________________________________________________________
> > > Be a better sports nut!  Let your teams follow you
> > > with Yahoo Mobile. Try it now.
> > > http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> > >
> >
>
>
>
>
>  ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Anita Kulshreshtha <a_...@yahoo.com>.
   It is not clear to me if this is part of the earlier code or a
separate program. If it is part of the JMX code, then Runtime is from
the local jvm not remote. The non heap Memory for this program in
either case is negligible.
   You could start G with -Dcom.sun.management.jmxremote. Start
jconsole and click on the Memory tab to get the whole picture.
   Hope this is helpful

Thanks
Anita

--- Vamsavardhana Reddy <c1...@gmail.com> wrote:

> I don't know why the non heap memory is missing in the equations. 
> The
> equations I gave are based what I observed by running the following
> code.
> 
>             MemoryMXBean memmxbean =
> ManagementFactory.getMemoryMXBean();
>             Runtime rt = Runtime.getRuntime();
>             MemoryUsage memUsage = memmxbean.getHeapMemoryUsage();
>             System.err.println("init="+memUsage.getInit());
>             System.err.println("max="+memUsage.getMax());
>             System.err.println("used="+memUsage.getUsed());
>             System.err.println("committed="+memUsage.getCommitted());
>             System.err.println("free="+(memUsage.getCommitted()-
> memUsage.getUsed()));
>             System.err.println("TotalMemory = "+rt.totalMemory());
>             System.err.println("MaxMemory = "+rt.maxMemory());
>             System.err.println("FreeMemory = "+rt.freeMemory());
>            
> System.err.println("Used="+(rt.totalMemory()-rt.freeMemory()));
> 
> ++Vamsi
> 
> On Dec 4, 2007 8:57 PM, Anita Kulshreshtha <a_...@yahoo.com>
> wrote:
> 
> >   IIUC,
> >
> >
>
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html
> >   runtime values are sum of values from Heap and non heap memory.
> In
> > other words you need to add contribution from non heap Memory to
> all 4
> > equations.
> >
> > Thanks
> > Anita
> >
> > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> >
> > > I don't know if it is necessary to add the statistics from
> Runtime.
> > > Here is
> > > the relationship I see between the stats from Runtime and those
> got
> > > from
> > > MemoryMXBean.getHeapMemoryUsage()
> > >
> > > Runtime.totalMemory() == MemoryUsage.getCommitted()
> > > Runtime.maxMemory() == MemoryUsage.getMax()
> > > Runtime.freeMemory() == MemoryUsage.getCommitted() -
> > > MemoryUsage.getUsed()
> > > Runtime.totalMemory() - Runtime.freeMemory() ==
> MemoryUsage.getUsed()
> > >
> > > ++Vamsi
> > >
> > >
> > > On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > > wrote:
> > >
> > > >   If you are interested in usedMemory and maxMemory as given by
> > > > Runtime, we could add that again. The JVM Stats give a rough
> > > estimate
> > > > of heap memory only.
> > > >
> > > > Thanks
> > > > Anita
> > > >
> > > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > > >
> > > > > I am wondering if the following (which works) is the correct
> way
> > > to
> > > > > get
> > > > > maxHeapSize and usedMemory from a remote Geronimo server.
> > > > >
> > > > > import
> > > > >
> org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> > > > >
> > > > >         Map map = new HashMap();
> > > > >         map.put("jmx.remote.credentials", new String[] {user,
> > > > > password});
> > > > >         JMXServiceURL address = new JMXServiceURL(
> > > > >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" +
> port
> > > +
> > > > > "/JMXConnector");
> > > > >         JMXConnector jmxConnector =
> > > > > JMXConnectorFactory.connect(address,
> > > > > map);
> > > > >         mbServerConnection =
> > > jmxConnector.getMBeanServerConnection();
> > > > >         objName = ObjectName.getInstance
> > > > > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> > > > >         Stats stats = (Stats)
> > > > > mbServerConnection.getAttribute(objName,
> > > > > "stats");
> > > > >          BoundedRangeStatisticImpl statistic =
> > > > > (BoundedRangeStatisticImpl)
> > > > > stats.getStatistic("HeapSize");
> > > > >         long maxMemory = statistic.getUpperBound();
> > > > >         long usedMemory = statistic.getCurrent();
> > > > >
> > > > > Is this ok?  Or, is there a better way?
> > > > >
> > > > > ++Vamsi
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
>
____________________________________________________________________________________
> > > > Be a better pen pal.
> > > > Text or chat with friends inside Yahoo! Mail. See how.
> > > > http://overview.mail.yahoo.com/
> > > >
> > >
> >
> >
> >
> >
> > 
>
____________________________________________________________________________________
> > Be a better sports nut!  Let your teams follow you
> > with Yahoo Mobile. Try it now.
> > http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> >
> 



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
I don't know why the non heap memory is missing in the equations.  The
equations I gave are based what I observed by running the following code.

            MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean();
            Runtime rt = Runtime.getRuntime();
            MemoryUsage memUsage = memmxbean.getHeapMemoryUsage();
            System.err.println("init="+memUsage.getInit());
            System.err.println("max="+memUsage.getMax());
            System.err.println("used="+memUsage.getUsed());
            System.err.println("committed="+memUsage.getCommitted());
            System.err.println("free="+(memUsage.getCommitted()-
memUsage.getUsed()));
            System.err.println("TotalMemory = "+rt.totalMemory());
            System.err.println("MaxMemory = "+rt.maxMemory());
            System.err.println("FreeMemory = "+rt.freeMemory());
            System.err.println("Used="+(rt.totalMemory()-rt.freeMemory()));

++Vamsi

On Dec 4, 2007 8:57 PM, Anita Kulshreshtha <a_...@yahoo.com> wrote:

>   IIUC,
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html
>   runtime values are sum of values from Heap and non heap memory. In
> other words you need to add contribution from non heap Memory to all 4
> equations.
>
> Thanks
> Anita
>
> --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
>
> > I don't know if it is necessary to add the statistics from Runtime.
> > Here is
> > the relationship I see between the stats from Runtime and those got
> > from
> > MemoryMXBean.getHeapMemoryUsage()
> >
> > Runtime.totalMemory() == MemoryUsage.getCommitted()
> > Runtime.maxMemory() == MemoryUsage.getMax()
> > Runtime.freeMemory() == MemoryUsage.getCommitted() -
> > MemoryUsage.getUsed()
> > Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed()
> >
> > ++Vamsi
> >
> >
> > On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com>
> > wrote:
> >
> > >   If you are interested in usedMemory and maxMemory as given by
> > > Runtime, we could add that again. The JVM Stats give a rough
> > estimate
> > > of heap memory only.
> > >
> > > Thanks
> > > Anita
> > >
> > > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> > >
> > > > I am wondering if the following (which works) is the correct way
> > to
> > > > get
> > > > maxHeapSize and usedMemory from a remote Geronimo server.
> > > >
> > > > import
> > > > org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> > > >
> > > >         Map map = new HashMap();
> > > >         map.put("jmx.remote.credentials", new String[] {user,
> > > > password});
> > > >         JMXServiceURL address = new JMXServiceURL(
> > > >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port
> > +
> > > > "/JMXConnector");
> > > >         JMXConnector jmxConnector =
> > > > JMXConnectorFactory.connect(address,
> > > > map);
> > > >         mbServerConnection =
> > jmxConnector.getMBeanServerConnection();
> > > >         objName = ObjectName.getInstance
> > > > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> > > >         Stats stats = (Stats)
> > > > mbServerConnection.getAttribute(objName,
> > > > "stats");
> > > >          BoundedRangeStatisticImpl statistic =
> > > > (BoundedRangeStatisticImpl)
> > > > stats.getStatistic("HeapSize");
> > > >         long maxMemory = statistic.getUpperBound();
> > > >         long usedMemory = statistic.getCurrent();
> > > >
> > > > Is this ok?  Or, is there a better way?
> > > >
> > > > ++Vamsi
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
> ____________________________________________________________________________________
> > > Be a better pen pal.
> > > Text or chat with friends inside Yahoo! Mail. See how.
> > > http://overview.mail.yahoo.com/
> > >
> >
>
>
>
>
>  ____________________________________________________________________________________
> Be a better sports nut!  Let your teams follow you
> with Yahoo Mobile. Try it now.
> http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Anita Kulshreshtha <a_...@yahoo.com>.
   IIUC,
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html
   runtime values are sum of values from Heap and non heap memory. In
other words you need to add contribution from non heap Memory to all 4
equations. 

Thanks
Anita

--- Vamsavardhana Reddy <c1...@gmail.com> wrote:

> I don't know if it is necessary to add the statistics from Runtime. 
> Here is
> the relationship I see between the stats from Runtime and those got
> from
> MemoryMXBean.getHeapMemoryUsage()
> 
> Runtime.totalMemory() == MemoryUsage.getCommitted()
> Runtime.maxMemory() == MemoryUsage.getMax()
> Runtime.freeMemory() == MemoryUsage.getCommitted() -
> MemoryUsage.getUsed()
> Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed()
> 
> ++Vamsi
> 
> 
> On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com>
> wrote:
> 
> >   If you are interested in usedMemory and maxMemory as given by
> > Runtime, we could add that again. The JVM Stats give a rough
> estimate
> > of heap memory only.
> >
> > Thanks
> > Anita
> >
> > --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
> >
> > > I am wondering if the following (which works) is the correct way
> to
> > > get
> > > maxHeapSize and usedMemory from a remote Geronimo server.
> > >
> > > import
> > > org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> > >
> > >         Map map = new HashMap();
> > >         map.put("jmx.remote.credentials", new String[] {user,
> > > password});
> > >         JMXServiceURL address = new JMXServiceURL(
> > >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port
> +
> > > "/JMXConnector");
> > >         JMXConnector jmxConnector =
> > > JMXConnectorFactory.connect(address,
> > > map);
> > >         mbServerConnection =
> jmxConnector.getMBeanServerConnection();
> > >         objName = ObjectName.getInstance
> > > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> > >         Stats stats = (Stats)
> > > mbServerConnection.getAttribute(objName,
> > > "stats");
> > >          BoundedRangeStatisticImpl statistic =
> > > (BoundedRangeStatisticImpl)
> > > stats.getStatistic("HeapSize");
> > >         long maxMemory = statistic.getUpperBound();
> > >         long usedMemory = statistic.getCurrent();
> > >
> > > Is this ok?  Or, is there a better way?
> > >
> > > ++Vamsi
> > >
> >
> >
> >
> >
> > 
>
____________________________________________________________________________________
> > Be a better pen pal.
> > Text or chat with friends inside Yahoo! Mail. See how.
> > http://overview.mail.yahoo.com/
> >
> 



      ____________________________________________________________________________________
Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
I don't know if it is necessary to add the statistics from Runtime.  Here is
the relationship I see between the stats from Runtime and those got from
MemoryMXBean.getHeapMemoryUsage()

Runtime.totalMemory() == MemoryUsage.getCommitted()
Runtime.maxMemory() == MemoryUsage.getMax()
Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed()
Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed()

++Vamsi


On Dec 4, 2007 6:51 PM, Anita Kulshreshtha <a_...@yahoo.com> wrote:

>   If you are interested in usedMemory and maxMemory as given by
> Runtime, we could add that again. The JVM Stats give a rough estimate
> of heap memory only.
>
> Thanks
> Anita
>
> --- Vamsavardhana Reddy <c1...@gmail.com> wrote:
>
> > I am wondering if the following (which works) is the correct way to
> > get
> > maxHeapSize and usedMemory from a remote Geronimo server.
> >
> > import
> > org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> >
> >         Map map = new HashMap();
> >         map.put("jmx.remote.credentials", new String[] {user,
> > password});
> >         JMXServiceURL address = new JMXServiceURL(
> >                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port +
> > "/JMXConnector");
> >         JMXConnector jmxConnector =
> > JMXConnectorFactory.connect(address,
> > map);
> >         mbServerConnection = jmxConnector.getMBeanServerConnection();
> >         objName = ObjectName.getInstance
> > ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
> >         Stats stats = (Stats)
> > mbServerConnection.getAttribute(objName,
> > "stats");
> >          BoundedRangeStatisticImpl statistic =
> > (BoundedRangeStatisticImpl)
> > stats.getStatistic("HeapSize");
> >         long maxMemory = statistic.getUpperBound();
> >         long usedMemory = statistic.getCurrent();
> >
> > Is this ok?  Or, is there a better way?
> >
> > ++Vamsi
> >
>
>
>
>
>  ____________________________________________________________________________________
> Be a better pen pal.
> Text or chat with friends inside Yahoo! Mail. See how.
> http://overview.mail.yahoo.com/
>

Re: How to get memory statistics from a remote Geronimo runtime?

Posted by Anita Kulshreshtha <a_...@yahoo.com>.
   If you are interested in usedMemory and maxMemory as given by
Runtime, we could add that again. The JVM Stats give a rough estimate
of heap memory only. 

Thanks
Anita

--- Vamsavardhana Reddy <c1...@gmail.com> wrote:

> I am wondering if the following (which works) is the correct way to
> get
> maxHeapSize and usedMemory from a remote Geronimo server.
> 
> import
> org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
> 
>         Map map = new HashMap();
>         map.put("jmx.remote.credentials", new String[] {user,
> password});
>         JMXServiceURL address = new JMXServiceURL(
>                 "service:jmx:rmi:///jndi/rmi://"+host+ ":" + port +
> "/JMXConnector");
>         JMXConnector jmxConnector =
> JMXConnectorFactory.connect(address,
> map);
>         mbServerConnection = jmxConnector.getMBeanServerConnection();
>         objName = ObjectName.getInstance
> ("geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM");
>         Stats stats = (Stats)
> mbServerConnection.getAttribute(objName,
> "stats");
>          BoundedRangeStatisticImpl statistic =
> (BoundedRangeStatisticImpl)
> stats.getStatistic("HeapSize");
>         long maxMemory = statistic.getUpperBound();
>         long usedMemory = statistic.getCurrent();
> 
> Is this ok?  Or, is there a better way?
> 
> ++Vamsi
> 



      ____________________________________________________________________________________
Be a better pen pal. 
Text or chat with friends inside Yahoo! Mail. See how.  http://overview.mail.yahoo.com/