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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
> > > 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 <[EMAIL PROTECTED]> 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 

Reply via email to