How to find the total and free memory available in RAM. and used & free space available in each disk

K

kathirvel.com

Hi,
How to find the total memory space and free space available
in RAM. and how to find the used and free space available in a Disk?
If there is any code please do provide me...

regards,
thanks,
kathir
 
S

Sebastian Millies

Am 2 Nov 2006 02:06:22 -0800 schrieb (e-mail address removed):
Hi,
How to find the total memory space and free space available
in RAM. and how to find the used and free space available in a Disk?
If there is any code please do provide me...

As for RAM, in old Java 1.3 code I did it this way:

Runtime rt = Runtime.getRuntime();
long free = rt.freeMemory();
long total = rt.totalMemory();
long used = rt.totalMemory() - rt.freeMemory();
double utilization = (double) used / (double) total;

I believe in 1.5 there may be other ways.

-- Sebastian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top