View the memory occupied by a program running in CentOS

Source: Internet
Author: User

View the memory occupied by a program running in CentOS

Method 1

Top-p process number
[yzy@node3 micro-service]$ top -p 20490top - 16:50:32 up 6 days, 2:18, 1 user, load average: 0.00, 0.01, 0.05Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stKiB Mem : 65876972 total, 51899292 free, 9988408 used, 3989272 buff/cacheKiB Swap: 32964604 total, 32964604 free, 0 used. 55522228 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20490 yzy 20 0 113252 1632 1272 S 0.0 0.0 0:35.50 sh 

Method 2

Ps-aux | grep process name
[zhoulu@node3 micro-service]$ ps -aux | grep eureka-auto.sh zhoulu 3716 0.0 0.0 112640 972 pts/0 S+ 16:49 0:00 grep --color=auto eureka-auto.shzhoulu 20490 0.0 0.0 113252 1632 ? S Apr14 0:35 /bin/sh ./eureka-auto.sh

Method 3

Cat/proc/process ID/status
[zhoulu@node3 micro-service]$ cat /proc/20490/statusName: shState: S (sleeping)Tgid: 20490Ngid: 0Pid: 20490PPid: 1TracerPid: 0Uid: 1019 1019 1019 1019Gid: 1019 1019 1019 1019FDSize: 256Groups: 1019 VmPeak: 113256 kBVmSize: 113252 kBVmLck: 0 kBVmPin: 0 kBVmHWM: 1632 kBVmRSS: 1632 kBVmData: 340 kBVmStk: 136 kBVmExe: 884 kBVmLib: 2044 kBVmPTE: 52 kBVmSwap: 0 kBThreads: 1SigQ: 0/257254SigPnd: 0000000000000000ShdPnd: 0000000000000000SigBlk: 0000000000010000SigIgn: 0000000000000005SigCgt: 0000000000010002CapInh: 0000000000000000CapPrm: 0000000000000000CapEff: 0000000000000000CapBnd: 0000001fffffffffSeccomp: 0Cpus_allowed: ffffCpus_allowed_list: 0-15Mems_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001Mems_allowed_list: 0voluntary_ctxt_switches: 102189nonvoluntary_ctxt_switches: 170

VmSize (KB) task virtual address space size (total_vm-reserved_vm), where total_vm is the size of the address space of the Process, reserved_vm: the size of the physical memory that the VmLck (KB) task has locked on the physical page of the process between the reserved or special memory. The locked physical memory cannot be exchanged to the physical memory used by the hard disk (locked_vm) VmRSS (KB) application. It is the value of the parameter rss of the ps command (rss) the size of the VmData (KB) Program Data Segment (the size of the virtual memory) that stores initialized data; (total_vm-shared_vm-stack_vm) The size of the VmStk (KB) task in the user State stack (stack_vm) vmExe (KB) program's executable virtual memory size, code segment, excluding the library used by the task (end_code-start_code) VmLib (KB) size of the database mapped to the virtual memory space of the task (exec_lib) VmPTE the size of all the page tables of the process. Unit: kb Threads shares the number of tasks using the signal descriptor, in POSIX multi-threaded applications, all threads in the thread group use the same signal descriptor.

1. VmRSS is the memory actually being occupied, while VmData is the virtual memory. There is no problem with the large size difference. 2. VmData refers to the memory size of the data segment, which stores the initialized data; (total_vm-shared_vm-stack_vm) 3. It is not calculated when the dynamic library is not called (dlopen Mode) 4. The static library will be compiled as part of the program itself, not included in the VmLib statistics. 5. Refer to the above description. 6. unless there is a very obvious memory leak, such as the memory has been greatly increased and will not be released for a long time, these values are just true internal leaks.

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.