?
Solved

Reading CPU, Memory and Thread utilization in java

Posted on 2004-08-25
12
Medium Priority
?
418 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 256 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 248 total points
ID: 11891448
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 248 total points
ID: 11891450
You can only find info about the memory that is allocated to the JVM by the OS.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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 248 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

770 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