• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program problem

 
gangs sandrani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai frnds, i am new to java development.... i just wanna to develop a program to print the physical memory occupied and no-of cpu cycles taken by an application in java....can any help me out which java classes to be used....
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Have you looked into any library yourself? In most cases a simple Google search will turn up many hits if you specify good keywords to search for ..

Cheers,
Wim
 
gangs sandrani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you wim, but i could not find any libraries/classes in google....can you give me a hint to start...
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the keywords 'java profiler' (or profiling).

Wim
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, gangs sandrani.

Writing a Java profiler, or something that can count the number of CPU cycles and exact memory usage of a Java program, is a quite advanced subject. In Java, the JVM normally shields you from low-level things like those.

The JDK comes with a nice application, VisualVM, that can analyze memory usage, threads, CPU usage etc. of Java processes. You can start it by typing jvisualvm in a command prompt window.
 
gangs sandrani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get process related information for an application running in task manager...

ImageName: firefox.exe
PID: 1234
CPU: 03%
Mem Usage: 22532K
Threads: 12


can any body tell me what all the methods(classes) to be used to get these information
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Things like that are unfortunately not easy to get at in Java, because they are low-level, operating system specific things. There are no classes in the standard Java API that can easily give you that information for arbitrary programs running on your computer.

If you really want to do it, you would have to write some native code (in for example C or C++) that does operating system specific calls to get the information; you could call your native code via JNI (Java Native Interface).
 
gangs sandrani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jesper de Jong ,
can you post me some example of native code....via JNI (Java Native Interface).
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't double post the same question. Your other thread has been locked.
 
gangs sandrani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok dude
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic