The Artima Developer Community
Sponsored Link

Java Buzz Forum
JDK 1.5: Monitoring the JVM

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Nick Lothian

Posts: 397
Nickname: nicklothia
Registered: Jun, 2003

Nick Lothian is Java Developer & Team Leader
JDK 1.5: Monitoring the JVM Posted: Jan 26, 2004 4:20 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Nick Lothian.
Original Post: JDK 1.5: Monitoring the JVM
Feed Title: BadMagicNumber
Feed URL: http://feeds.feedburner.com/Badmagicnumber
Feed Description: Java, Development and Me
Latest Java Buzz Posts
Latest Java Buzz Posts by Nick Lothian
Latest Posts From BadMagicNumber

Advertisement

JDK 1.5 contains a number of useful interfaces to monitor the performance of the JVM. This includes support for both Memory and CPU usage. These metrics are exposed via JMX as well as via plain interfaces in the JDK.

The code below iterates over the different elements in the memory pool and prints out their current statistics.


    List mpMBList = ManagementFactory.getMemoryPoolMBeans();
    for (Iterator iter = mpMBList.iterator(); iter.hasNext(); ) {
        MemoryPoolMBean element = (MemoryPoolMBean) iter.next();
        System.out.println(element.getName() + " " + element.getPeakUsage());
    }

Output:


Code Cache initSize = 196608, used = 450112, committed = 458752, maxSize = 33554432
Eden Space initSize = 524288, used = 518712, committed = 524288, maxSize = -1
Survivor Space 1 initSize = 65536, used = 0, committed = 65536, maxSize = -1
Survivor Space 2 initSize = 65536, used = 65528, committed = 65536, maxSize = -1
Tenured Gen initSize = 1441792, used = 42944, committed = 1441792, maxSize = 61997056
Perm Gen initSize = 8388608, used = 1718928, committed = 8388608, maxSize = 67108864

The information you get is similar to what you can get using the JVM Stat tool in Sun's JDK 1.4.2 VM.

Read: JDK 1.5: Monitoring the JVM

Topic: Rich Client Strikes Back? Previous Topic   Next Topic Topic: Task Switcher for Symbian Devices

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use