1

Hi and thanks in advance.

What is the difference between the memory in the tasklist ( which you run in the cmd) and that GUI task manager. I noticed for browser processes, that the memory is off by a great deal. Which is more accurate of the process's memory.

Neo84
  • 197
  • 2
  • 18

1 Answers1

1

Task Manager has lots of memory counters see View menu - Select Columns.

The standard one shown is private working set. This is a/ private - so only bytes in memory specific to this program (so no shell32 common code is counted) and b/ working set - the amount of memory mapped and present in that processes address space.

Even memory not present in address space may be in physical memory as on the standby list or in the file cache or being used by another program. It only requires flicking a bit to make it available to the process. Run two copies of notepad, notepad in now in the file cache (and being small) in two processes. But the code is only in memory once not three times.

If you want to make your own tasklist.

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")

For Each objItem in colItems
'   If objitem.Name = "mspaint.exe" Then
        wscript.echo objitem.name & " PID=" & objItem.ProcessID & " SessionID=" & objitem.sessionid
'       objitem.terminate
'   End If
Next

Lines starting with a ' are commented out.

To use in a command prompt

cscript //nologo c:\path\script.vbs

These are the properties

Property                Type            Operation
========                ====            =========
CSName                              N/A                     N/A       
CommandLine                         N/A                     N/A       
Description                         N/A                     N/A       
ExecutablePath                      N/A                     N/A       
ExecutionState                      N/A                     N/A       
Handle                              N/A                     N/A       
HandleCount                         N/A                     N/A       
InstallDate                         N/A                     N/A       
KernelModeTime                      N/A                     N/A       
MaximumWorkingSetSize               N/A                     N/A       
MinimumWorkingSetSize               N/A                     N/A       
Name                                N/A                     N/A       
OSName                              N/A                     N/A       
OtherOperationCount                 N/A                     N/A       
OtherTransferCount                  N/A                     N/A       
PageFaults                          N/A                     N/A       
PageFileUsage                       N/A                     N/A       
ParentProcessId                     N/A                     N/A       
PeakPageFileUsage                   N/A                     N/A       
PeakVirtualSize                     N/A                     N/A       
PeakWorkingSetSize                  N/A                     N/A       
Priority                            N/A                     N/A       
PrivatePageCount                    N/A                     N/A       
ProcessId                           N/A                     N/A       
QuotaNonPagedPoolUsage              N/A                     N/A       
QuotaPagedPoolUsage                 N/A                     N/A       
QuotaPeakNonPagedPoolUsage          N/A                     N/A       
QuotaPeakPagedPoolUsage             N/A                     N/A       
ReadOperationCount                  N/A                     N/A       
ReadTransferCount                   N/A                     N/A       
SessionId                           N/A                     N/A       
Status                              N/A                     N/A       
TerminationDate                     N/A                     N/A       
ThreadCount                         N/A                     N/A       
UserModeTime                        N/A                     N/A       
VirtualSize                         N/A                     N/A       
WindowsVersion                      N/A                     N/A       
WorkingSetSize                      N/A                     N/A       
WriteOperationCount                 N/A                     N/A       
WriteTransferCount                  N/A                     N/A       

And the methods

Call            [ In/Out ]Params&type           Status
====            =====================           ======
AttachDebugger                              (null)         
Create                  [IN ]CommandLine(STRING)                (null)         
            [IN ]CurrentDirectory(STRING)           
            [IN ]ProcessStartupInformation(OBJECT)  
            [OUT]ProcessId(UINT32)                  
GetOwner                [OUT]Domain(STRING)                     (null)         
            [OUT]User(STRING)                       
GetOwnerSid             [OUT]Sid(STRING)                        (null)         
SetPriority             [IN ]Priority(SINT32)                   (null)         
Terminate               [IN ]Reason(UINT32)                     (null)         

Which is the same as

wmic process where name='notepad.exe' get /format:list

Further reading

https://msdn.microsoft.com/en-us/library/ms810627.aspx

https://www.labri.fr/perso/betrema/winnt/ntvmm.html (this no longer appears on the MSDN)

user5071892
  • 147
  • 2