Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process size on UNIX

Tags:

unix

size

What is the correct way to get the process size on Solaris, HP-UX and AIX? Should we use top or ps -o vsz or something else?

like image 583
sachin Avatar asked Aug 04 '08 07:08

sachin


People also ask

How do I check the size of a process in Linux?

You can check memory of a process or a set of processes in human readable format (in KB or kilobytes) with pmap command. All you need is the PID of the processes you want to check memory usage of. As you can see, the total memory used by the process 917 is 516104 KB or kilobytes.

How do you find the top 5 memory consuming process in Unix?

Use ps Command to Find Top Processes by Memory and CPU Usage ps is a Linux command-line utility with many options that helps you to display output in different formats. You can use the ps command with –sort argument to sort the output by memory and CPU usage.

How do I check memory usage on PID?

The ps command can also be used to monitor memory usage of individual processes. The ps v PID command provides the most comprehensive report on memory-related statistics for an individual process, such as: Page faults. Size of working segment that has been touched.

What is Unix page size?

The entries in a page table are 4 bytes on a 32-bit machine each because they are pointers to pages. Since the page tables have a 10 bit index and 4 byte entries, the size of the page table is 2^10 * 4 = 4096 bytes.


2 Answers

The exact definitions of vsize, rss, rprvt, rshrd, and other obscure-looking abbreviations vary from OS to OS. The manual pages for the top and ps commands will have some sort of description, but all such descriptions are simplified greatly (or are based on long-extinct kernel implementations).
"Process size" as a concept is fiendishly difficult to pin down in the general case. Answers in specific instances depend heavily on the actual memory management implementation in the OS, and are rarely as satisfying as the tidy "process size" concept that exists in the minds of most users (and most developers).

For example, none of those numbers (nor, likely, any combination of them) can be used to tell you exactly how many such processes can run at once in a given amount of free memory. But really, your best bet is to come at it from that end: why do you want this number, and what will you use it for? Given that information, I think you'll get more useful answers.

like image 98
John Siracusa Avatar answered Sep 20 '22 19:09

John Siracusa


On Solaris, you can get detailed information on a process's memory usage with the pmap command. In particular, pmap -x <pid> shows you how much of a process's memory is shared and how much is specifically used by that process. This is useful for working out the "marginal" memory usage of a process -- with this technique you can avoid double-counting shared libraries.

like image 20
TLS Avatar answered Sep 17 '22 19:09

TLS