Locating memory leaks

If the memory usage of a Linux program is abnormally high, there may be a memory leak. At this time, you should pay attention to the memory usage of the file system, shared memory, and memory usage of each business process. You can use top to view the CPU usage of each process.
insert image description here
VIRT represents the size of virtual memory used by the process, RES represents the size of physical memory used by the process, SHR represents the size of shared memory used by the process, and %MEM represents the percentage of physical memory used by the process.

VIRT: malloc application, not necessarily used immediately.
RES: Only increases when the memory is used.
After malloc applies for memory and memset, only VIRT grows, RES does not grow, and RES grows after use.

If you want to see the memory and CPU usage of each thread, you can type H:
insert image description here
type 1 to view the CPU usage of each core:
insert image description here

Guess you like

Origin blog.csdn.net/hhhlizhao/article/details/129771171