I want to have a small batch script which runs on a server and every hour logs memory statistics. I already have the script log the process-specific info I want via other tools, but I want to know of a way (either directly on cmd or via a program) which will output the total committed memory of the system. In other words, I think the commit charge total statistic in the Task Manager is what I want to know, but via the command line:
2 Answers
You can instantiate and use the Win32_PerfFormattedData_PerfOS_Memory class for this via VBScript:
Set wmiObject = GetObject("winmgmts:\\.\root\cimv2:Win32_PerfFormattedData_PerfOS_Memory=@")
Wscript.Echo "CommitLimit (B): " & wmiObject.CommitLimit
Wscript.Echo "CommitLimit (MB): " & (wmiObject.CommitLimit / 1048576)
Wscript.Echo "CommittedBytes (B): " & wmiObject.CommittedBytes
Wscript.Echo "CommittedBytes (MB): " & (wmiObject.CommittedBytes / 1048576)
Save with a name like GetMem.vbs and invoke using cscript //Nologo GetMem.vbs
. The class can also be used via the wmic
command as mentioned below, although of course a script provides you much more flexibility.
-
-
1@STTR: He wants Commit Charge Total. Isn't that the same as CommittedBytes? The values certainly seem to match on my PC.– KaranJun 26, 2013 at 18:42
-
1blog.whatsupduck.net/2010/05/… it not :
wmic path Win32_PerfFormattedData_PerfOS_Memory get CommittedBytes, CommitLimit
– STTRJun 26, 2013 at 18:51 -
@STTR: That blog post you linked to agrees with me. CommittedBytes is Commit Charge Total. Neither the OP nor I mentioned Commit Charge Peak, so I honestly fail to see what the problem is.– KaranJun 26, 2013 at 18:59
-
wmic path Win32_PerfFormattedData_PerfOS_Memory get CommittedBytes, CommitLimit
Test script ...
These values may be equal so long until RAM exhaustible (CommitLimit and PeakCommitment*(page size))
Peak ...
Querying Peak Commit Bytes with Powershell (via NtQuerySystemInformation)
-
1The OP wants Total, not Peak. I must confess I still don't see what you're driving at.– KaranJun 26, 2013 at 19:27
-
@Karan Well, OP wanted to Peak). It is best to use
perfmon
and save the results in a database. Let the OP will clarify the question)– STTRJun 26, 2013 at 19:48 -
1Karan is correct. It is currently the total (not peak) I am interested in. Also, I would add a link to that article in your answer so others know what you're referring to when you use the "PeakCommitment.ps1" command in your screenshots Jun 26, 2013 at 20:16
-
@AlexanderBird script at Querying Peak Commit Bytes with Powershell (via NtQuerySystemInformation) article– STTRJun 26, 2013 at 20:22