Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Java in General
How To get Heap Memory Used
Tanzy Akhtar
Ranch Hand
Posts: 110
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am using JMX way to get heap memory.
Used the following code to--
public class JMXTest { private static final String DEFAULT_DOMAIN_NAME = "144.120.521.231:9696"; public static void main(String[] args) throws Exception { MBeanServer mbs = getMBeanServer(); System.out.println("------------------------------------"); JMXServiceURL url = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://144.120.521.231:9696/jmxrmi"); JMXConnector cntor = JMXConnectorFactory.connect(url); MBeanServerConnection connection = cntor.getMBeanServerConnection(); ObjectName objNameMembers = new ObjectName("java.lang:type=Memory"); System.out.println("test started : " + connection.getObjectInstance(objNameMembers).getClassName()); }
It's working fine as of now.
But i need to get the value of heapmemory used.
Anybody suugest how to achieve it?
Roll with punchers, there is always tomorrow.
Techie Blog --
http://jtanzy.blogspot.com/
Karthik Shiraly
Bartender
Posts: 1210
25
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Tanzy,
The object returned is a MemoryMXBean, so cast to it and use its
methods
.
Cheers
Karthik
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
MBean question
jmxbean classcast exception
JMX error: NameNotFoundException
Suspending/Pausing a MDB's Consumption Programmatically
Printing Data
More...