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....
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.
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).
Joined: Jul 06, 2011
Thank you Jesper de Jong ,
can you post me some example of native code....via JNI (Java Native Interface).