Measuring memory per Unix process
Wow, it's been a long time since I've written anything here. Since my last blog post, I've been taking two classes (in two very different topics), along with the other daily responsibilities of working, raising two children, etc.
For a work-related requirement, I had to figure out how to measure memory consumed by a specific Unix/Linux process. This is more difficult than it may seem.
For one thing, apparently the memory statistics given by Linux are meaningless. This is mainly because the ps command (and the VSZ metric specifically) only lists the size of the address space referenced by a process, not the actual memory size itself. This page suggests the use of smaps, where /proc/$pid/smaps provides the actual amount of memory used by a process.
Because the output of smaps is pretty lengthy, Someone wrote a python script called mem_usage.py to make the output more understandable.
The main issue is that smaps only exists in Linux, and I had a requirement to measure memory usage in OS X too. OS X doesn't even support the /proc concept so I couldn't use smaps.
In the end, I wound up going back to ps and relying on the RSS (resident set size) metric. It's displayed on multiple operating systems and indicates how much RAM is being used for the text and data segments for a specific process in kilobytes.
11:52:44[~/ruby:162]$ ps u
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
rpark 2668 0.6 1.4 1652720 44816 s000 S 12:40AM 5:01.71 ./eclipse
rpark 4598 0.0 0.1 2435088 1800 s001 S+ 11:01PM 0:00.09 ssh rpark@1
rpark 2878 0.0 1.2 2769524 36688 s000 S 1:17AM 0:25.44 /System/Lib
rpark 799 0.0 0.0 2435468 792 s001 S Tue12PM 0:00.18 -bash
rpark 535 0.0 0.0 2435468 756 s000 S Tue11AM 0:00.30 -bash
Here are some more discussions on this topic.
For a work-related requirement, I had to figure out how to measure memory consumed by a specific Unix/Linux process. This is more difficult than it may seem.
For one thing, apparently the memory statistics given by Linux are meaningless. This is mainly because the ps command (and the VSZ metric specifically) only lists the size of the address space referenced by a process, not the actual memory size itself. This page suggests the use of smaps, where /proc/$pid/smaps provides the actual amount of memory used by a process.
Because the output of smaps is pretty lengthy, Someone wrote a python script called mem_usage.py to make the output more understandable.
The main issue is that smaps only exists in Linux, and I had a requirement to measure memory usage in OS X too. OS X doesn't even support the /proc concept so I couldn't use smaps.
In the end, I wound up going back to ps and relying on the RSS (resident set size) metric. It's displayed on multiple operating systems and indicates how much RAM is being used for the text and data segments for a specific process in kilobytes.
11:52:44[~/ruby:162]$ ps u
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
rpark 2668 0.6 1.4 1652720 44816 s000 S 12:40AM 5:01.71 ./eclipse
rpark 4598 0.0 0.1 2435088 1800 s001 S+ 11:01PM 0:00.09 ssh rpark@1
rpark 2878 0.0 1.2 2769524 36688 s000 S 1:17AM 0:25.44 /System/Lib
rpark 799 0.0 0.0 2435468 792 s001 S Tue12PM 0:00.18 -bash
rpark 535 0.0 0.0 2435468 756 s000 S Tue11AM 0:00.30 -bash
Here are some more discussions on this topic.
7 Comments:
PLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | Embedded System Training in Chennai | Embedded Training in Chennai | VLSI Training in Chennai | VLSI Training Institute in Chennai
PLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | PLC SCADA Training in Chennai | Automation Training Institute in Chennai | PLC Training in Kerala
Embedded Training in Chennai | Best Embedded Training in Chennai | Embedded System Training in Chennai | Embedded System Training Institute in Chennai | Best Embedded System Training Institute in Chennai | Embedded Course in Chennai | Embedded System Training Institutes in Chennai | Embedded System Training Center in Chennai | Best Embedded System Training in Chennai | Embedded Systems Training in Chennai | VLSI Training in Chennai | VLSI Training Institute in Chennai
VLSI Training in Chennai | Best VLSI Training in Chennai | VLSI Training Centres in Chennai | VLSI Courses in Chennai | VLSI Training Courses in Chennai | VLSI Training Institute in Chennai | VLSI Training Institutes in Chennai | Best VLSI Training Institute in Chennai
Great Article
Project Centers in Chennai
Final Year Projects for CSE
It's very useful blog post with inforamtive and insightful content and i had good experience with this information.I have gone through CRS Info Solutions Home which really nice. Learn more details About Us of CRS info solutions. Here you can see the Courses CRS Info Solutions full list. Find Student Registration page and register now. Go through Blog post of crs info solutions. I just read these Reviews of crs really great. You can now Contact Us of crs info solutions. You enroll for Pega Training at crs info solutions.
Great Article
Cyber Security Projects
projects for cse
Networking Projects
JavaScript Training in Chennai
JavaScript Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Post a Comment
Subscribe to Post Comments [Atom]
<< Home