Get the App
SLTechnology News&Howtos  ›  Development  › 

How to check the memory occupied by a process in Linux

Shulou Source: shulou.com Published: 2022-06-01 22:02:08 10月04日 Update

This article mainly introduces "how to check the memory occupied by the process in Linux". In the daily operation, I believe that many people have doubts about how to view the memory occupied by the process in Linux. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to check the memory occupied by the process in Linux". Next, please follow the editor to study!

To view the memory occupied by a process under Linux, you can first find the process id by using the ps command, such as ps-ef | grep kafka can see the process id of the kafka program.

You can see that it is 2913, and you can now view the memory using the following command:

Top-p 2913

In this way, you can see the CPU and memory occupancy in real time, and then press Q to go back to the command line.

You can also use the ps command to view: ps-aux | grep kafka

The first mark is CPU and memory usage, and the next 943100 is physical memory usage, in k, so kafka takes up about 943m of memory.

You can also view the status file of the process: cat / proc/2913/status

The corresponding value of VmRSS is physical memory usage, which is about 943m, which is the same as just now.

In addition, you can dynamically view the memory footprint through the top command

Check the top 10 memory-consuming programs through: ps aux | sort-k4jue 4nr | head-n 10

At this point, the study on "how to view the memory occupied by a process in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Memory process command learning dynamic can pass more physics usage program help practical consistent next usage unit place real-time that is file Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Apple Microsoft OPPO Reno