Technology Encyclopedia Home >How to view the memory size occupied by a single process on the server?

How to view the memory size occupied by a single process on the server?

To view the memory size occupied by a single process on a server, you can use system commands depending on the operating system.

On Linux/Unix-based systems:

  1. ps command:

    ps -o pid,rss,comm -p <PID>
    
    • pid: Process ID
    • rss (Resident Set Size): Memory used by the process in kilobytes
    • comm: Command name

    Example:

    ps -o pid,rss,comm -p 1234  
    
  2. top or htop command:
    Run top or htop, then press Shift+M to sort processes by memory usage.

  3. pmap command:

    pmap -x <PID> | grep total  
    

    This provides a detailed memory map of the process.

On Windows systems:

  1. Task Manager:

    • Open Task Manager (Ctrl+Shift+Esc), go to the "Details" tab, and check the "Memory (Active Private Working Set)" column.
  2. tasklist command:

    tasklist /FI "PID eq <PID>" /FO TABLE /NH  
    

    (Note: This shows working set memory, not exact RSS.)

  3. Process Explorer (Sysinternals tool):
    A more detailed tool to inspect process memory usage.

Cloud Server Example (Tencent Cloud CVM):

If you're using a Tencent Cloud CVM (Cloud Virtual Machine), you can log in via SSH (Linux) or RDP (Windows) and use the above commands. For automated monitoring, Tencent Cloud provides Cloud Monitor (CM) to track process-level resource usage.

Example (Linux on Tencent Cloud CVM):

ps -eo pid,rss,comm | grep nginx  

This shows memory usage for all nginx processes.

For long-term monitoring, integrate Tencent Cloud CM to set alerts on high memory consumption.