Introduction to the memory methods used in viewing a program under Linux

Source: Internet
Author: User

Introduction to the memory methods used in viewing a program under Linux


When developing and operating on Linux, it is unavoidable to look at the memory consumed by a program. Common methods are summarized as follows (note the fourth method):

First type: Ps-aux | grep process_name

For example: now you want to monitor the memory of/USR/BIN/SSHD, first to find the PID, and then use top for targeted monitoring, RES is the memory value, see the next two graphs: 650) this.width=650; "Src=" https:// S3.51cto.com/wyfs02/m00/93/27/wkiol1kii4thfsqdaaakwdrvle8194.png "title=" 11.PNG "alt=" Wkiol1kii4thfsqdaaakwdrvle8194.png "/>

Top-p 1231, as follows: 650) this.width=650; "Src=" Https://s3.51cto.com/wyfs02/M02/93/28/wKioL1kIi_ Mqqw4aaaawvdqix78669.png "title=" 11.PNG "alt=" Wkiol1kii_mqqw4aaaawvdqix78669.png "/>

The second kind: top-p PID View program case as shown!

The third type: Cat/proc/pid/status

This will print out the details of the current process, where memory is Vmrss.
Note: The PID is to be replaced with an ID number.

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/93/28/wKioL1kIjWzze_HqAABIaZ6bUdY560.png "title=" 11. PNG "alt=" Wkiol1kijwzze_hqaabiaz6budy560.png "/>

!!! Fourth: Linux View the processes that occupy the highest memory

ps aux|head-1;ps aux|grep-v pid|sort-rn-k +4|head
or Top (then press p, note that this is capitalized), as follows:


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/93/28/wKioL1kIjjHweCYTAABNoNqocC4329.png "title=" 11. PNG "alt=" Wkiol1kijjhwecytaabnonqocc4329.png "/>

This combination of commands is actually the following two lines of command:
PS aux|head-1ps aux|grep-v pid|sort-rn-k +3|head
the first sentence is primarily to get the title (USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND).
the next grep-v pid is to remove the title of the PS aux command, that is, grep does not contain the three-letter combination of the PID line, and then the result is sorted using sort.
sort-rn-k +3 the-rn R in this command is ordered in reverse order, n is sorted by numeric size, and-K +3 is sorted for the contents of column 3rd, and the first 10 rows of data are obtained by using the Head command. (where | represents a pipeline operation)

Extended:

Linux viewing processes that occupy the highest CPU
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +3|head
or top (then press m, note that this is uppercase)

This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1921273

Introduction to the memory methods used in viewing a program under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.