- Documentation
Elastic Compute Service
Elastic Compute Service
Troubleshooting
Operating system issue
Linux operating system issue
When starting a service in the Linux instance, the prompt appears: task: Cannot allocate memory
Linux operating system issue
When starting a service in the Linux instance, the prompt appears: task: Cannot allocate memory
When starting a service in the Linux instance, the prompt appears: task: Cannot allocate memory
You can resolve the error of task: Cannot allocate memory that occurs when an ECS instance starts a certain service process by increasing the value of kernel.pid_max.
tip
This operation is only applicable to kernel versions earlier than v4.1. For kernel versions v4.1 and later, you can submit a ticket or contact your account manager to obtain technical support. It may be caused by the operating system exceeding the limit on the number of processes.
The Linux kernel limits the number of processes through the kernel configuration argument kernel.pid_max. When the total number of processes running services exceeds the value of kernel.pid_max, creating new processes will result in the system prompting the error task: Cannot allocate memory.
- View whether the number of processes currently running in the system exceeds the maximum number of processes.
- Run the following command to view the number of processes currently running in the system.
-
- Execute the following command to view the maximum number of processes in the system.
-
- If the current number of running processes in the system exceeds the maximum number of processes, please adjust the kernel.pid_max configuration item to a reasonable value according to the actual business situation. Once the adjustment is complete, it will take effect immediately.
Description
- After the kernel.pid_max value adjustment, it will take effect immediately.
- If the current number of running processes in the operating system exceeds two-thirds of the maximum number of processes (kernel.pid_max), it is also recommended to immediately increase the value of kernel.pid_max to avoid affecting subsequent business operations.
- Temporary Settings: Execute any one of the following commands to temporarily increase the value ofkernel.pid_max. However, it will become invalid after restarting the instance.
tip
Please replace expectedPidMaxValue in the command with the actual value that kernel.pid_max needs to be raised to.
- Permanent Settings: Execute the following command to permanently increase the value ofkernel.pid_max regardless of the instance status.
tip
Please replace expectedPidMaxValue in the command with the actual value that kernel.pid_max needs to be increased to.
Last updated: 2026.04.13 16:50:03