Hi,
I'd like to know if it is possible to collect information about the use of
the CPU,
the use of the memory and other parameters of the PC from a java program.
I've heard about JVMPI-JVMTI, but it would make me write code in C/C++.
Does it exist a strategy in java?
Thanks!
Simon OUALID - 18 Jun 2005 10:52 GMT
> Hi,
> I'd like to know if it is possible to collect information about the use of
[quoted text clipped - 3 lines]
> Does it exist a strategy in java?
> Thanks!
Runtime.getRuntime().freeMemory();
Runtime.getRuntime().totalMemory();
Runtime.getRuntime().maxMemory();
Runtime.getRuntime().availableProcessors();
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#freeMemory()
But it will only give you stats informations the JVM's memory (heap size).
wazary - 19 Jun 2005 15:20 GMT
> Runtime.getRuntime().freeMemory();
> Runtime.getRuntime().totalMemory();
> Runtime.getRuntime().maxMemory();
> Runtime.getRuntime().availableProcessors();
I know these methods, but they can't tell me
any information about the CPU in term of
charge, business, etc.
Andrew Thompson - 19 Jun 2005 15:32 GMT
>> Runtime.getRuntime().freeMemory();
>> Runtime.getRuntime().totalMemory();
[quoted text clipped - 4 lines]
> any information about the CPU in term of
> charge,
Charge?
>..business,
Business?? What the heck are you on about?
Do you mean - 'CPU chip takes +5 Volts and is made by AMD'?

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Ingo R. Homann - 20 Jun 2005 08:07 GMT
Hi pira,
> Hi,
> I'd like to know if it is possible to collect information about the use of
[quoted text clipped - 3 lines]
> Does it exist a strategy in java?
> Thanks!
Using Java5, take a look at the java.lang.management-package. The
ThreadMBean provides some information on CPU usage, IIRC. There are some
ohter interesting classes, although I didn't work with them...
Hth,
Ingo