Solved

Reading CPU, Memory and Thread utilization in java

Posted on 2004-08-25
12
415 Views
Last Modified: 2010-05-19
hi,
i need to read cpu utilization,memory utilization and threads of java application. I need to read this information through java programming. can anyone help me out?
Thanks in advance
Mahesh
0
Comment
Question by:MMaheshwaran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 5

Accepted Solution

by:
TrekkyLeaper earned 64 total points
ID: 11891410
If you're using UNIX, you can try parsing the results of a ps command. Otherwise, I think you will have to use some native code to do this.
0
 
LVL 12

Assisted Solution

by:Giant2
Giant2 earned 62 total points
ID: 11891448
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 62 total points
ID: 11891450
You can only find info about the memory that is allocated to the JVM by the OS.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:MMaheshwaran
ID: 11891903
i need it in windows 2000. i have explored some of the java profiling agent. It makes use of JVMPI to read resource utilization(  JFluid Netbeans plugin ). is it possible to use JVMPI to read this information?

mahesh
0
 
LVL 35

Expert Comment

by:girionis
ID: 11892001
I am not sure. But for any memory or process utilization you want to do *outside* the JVM you will need to use native code.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11899904
See the link I posted before!
I believe it could be interesting for you.
(I point at a code in JNI doing what you want).
http://www.codeguru.com/Cpp/misc/misc/assemblylanguage/article.php/c3847/

Bye, Giant.
0
 

Assisted Solution

by:brosouille
brosouille earned 62 total points
ID: 11901713
-Memory
Use java.lang.Runtime

-Thread
In a file thread.jsp

<pre>
<%
            ThreadGroup tg = Thread.currentThread().getThreadGroup();
            while (tg.getParent() != null) {
                  tg = tg.getParent();            
            }
      
            Thread threads[] = new Thread[5000];
            tg.enumerate(threads,true);

            for(int i = 0 ; i < threads.length ;i++) {

                  Thread t = threads[i];
                  if (null != t) {
                        String name = t.getName();
                        int pri = t.getPriority();
                        String group = t.getThreadGroup().getName();
                        out.println("thread '" +name+"' of ["+group+"] ; prior "+pri+" alive="+t.isAlive()+" interrupted="+t.isInterrupted()+" daemon="+t.isDaemon());
                  }
            }

%>

0
 
LVL 12

Expert Comment

by:Giant2
ID: 12256364
I think a split or a delete.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12256649
I think the question is already answered so a split woudl be nice :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat startup error 5 160
hashmap order 17 58
maven not picking latest jar instead picking old jar from .m2 12 72
American Express @Work site and Java 4 90
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importingā€¦
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question