While doing Performance testing, in addition to response
times we need to understand how much OS-Resource our system consumes.
OS-Resource might involve monitoring things like Memory,CPU and Network I/O.
While working on a Multi-process or Multi-threaded applications and comparing
memory consumption among them, it is very important to know how one calculates
the memory.
There
are various ways to look at the memory of a process. Let’s look at a on-premise
machine (Cent-OS) to look at the memory of a process
On using a “top” a linux based tool, I got the above memory
snapshot for different “top” processes. So, which one should one consider for memory?
VIRT – virtual size of a process where it holds the memory
within its process, memory shared with other processes and shared libraries.
RES – residential size of process which will accurately
provide the physical size of the defined process (Code + Data)
SHR – Shared memory indicates the memory consumed by the
shared libraries which are indicated in the virtual size of the process.
Now at a glance, If I need to understand the memory consumed
by a process I would go for the “Residential
size” of the process. Residential size
actually gives us the accurate memory consumption of the process.
Now let’s say that you would like to monitor or look for “Core
Memory” of a process. When running applications in Production, you might want
to look at how much memory does the process itself takes (which does not
include any memory of the shared libraries which might also be related to
memory shared with other processes). So to calculate that you might need to
look for the below formulae
Core-Memory = RES – SHR.
The same kind of convention applies for windows too. There
we call it as working set and private working set. You can configure your “task
manager” to show which ever kind of memory(by default it shows private working
set). If you wish to do it through script then you can use the windows API “WMIObject”.
Here’s a snippet
Get-WmiObject -class
Win32_PerfFormattedData_PerfProc_Process | where{$_.idprocess -eq $processId} |
select `
@{Name="Process Id"; Expression =
{$_.idprocess}},`
@{Name="Counter Name"; Expression =
{$_.name}},`
@{Name="CPU Usage";
Expression = {$_.PercentProcessorTime}},`
@{Name="Private Working Set";
Expression = {$_.workingSetPrivate / 1mb}}
This should help you understand how much memory is your
process used and which one adds significance
No comments:
Post a Comment