Jump to content


Photo

How to measure available RAM


  • Please log in to reply
3 replies to this topic

#1 martico

martico
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 April 2006 - 08:20 AM

Can anyone tell me if there is an PHP function to return the amount of available RAM. We have what looks like a memory leak issue on an XP system running Apache and it would be nice to be able to monitor the available RAM remotely.

Thanks.

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 24 April 2006 - 12:17 PM

I don't know of anything in PHP that can do this, but it might be possible. You may have to set something up on the server that will get the info for you and put it in a text file and then PHP can read the text file and display the results.

Info: PHP Manual


#3 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 April 2006 - 07:28 PM

Just tested this on my WinXP Pro box and works ok - Bare in mind I have a processor with hyperthreading enabled so the output index might be different for the available memory compared to the machine you may run it on - If it is incorrect, run print_r($output) to get the correct index.
<?php
exec("systeminfo",$output)
echo $output[26];
?>
Hope this helps.

NOTE: I have left the semi-colon off of the end of the exec() line as it appears I can't post with it there - Looks like a forum bug...

#4 martico

martico
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 April 2006 - 10:44 AM

[!--quoteo(post=368105:date=Apr 24 2006, 08:28 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Apr 24 2006, 08:28 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Just tested this on my WinXP Pro box and works ok - Bare in mind I have a processor with hyperthreading enabled so the output index might be different for the available memory compared to the machine you may run it on - If it is incorrect, run print_r($output) to get the correct index.
<?php
exec("systeminfo",$output)
echo $output[26];
?>
Hope this helps.

NOTE: I have left the semi-colon off of the end of the exec() line as it appears I can't post with it there - Looks like a forum bug...
[/quote]

Many thanks to both of you for replying - the "systeminfo" seems a great way to go.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users