tencent cloud

Cloud Virtual Machine

Release Notes and Announcements
Release Notes
Public Image Release Notes
Official End of Support Plan for the Operating System
Announcements
Product Introduction
CVM Overview
Strengths
Basic Concepts
Regions and Zones
Tutorial
Service Regions and Service Providers
Billing
Billing Overview
Billing Modes
Billing Items
Billing Mode Conversion Overview
Purchasing Instances
Configuration Adjustment Billing Guide
Overdue Payments
Getting Started
Purchasing a Customized Linux Instance
Purchasing a Customized Windows Instance
User Guide
Operation Guide Overview
Use Limits
Instances
Spot Instances
Reserved Instances
Images
Storage
Backup and Restoration
Network
Security
Passwords/Keys
Monitoring and Alarms
Ops Management
Convenience Features
Migrating a Server
Online Migration
Migration Consultation
Troubleshooting
CVM Login Failures
Windows Instance Login Failures
Linux Instance Login Failures
Other Login Failures
Instance Running Failures
Linux Instance Memory Failures
Network Failures
Use Cases
Suggestions on CVM Model Selection
Environment Building
Website Building
Application Building
Visual GUI Building
Uploading Local Files to CVM
Network Performance Test
Other Practical Tutorials
API Documentation
History
Introduction
API Category
Making API Requests
Region APIs
Instance APIs
Cloud Hosting Cluster APIs
Image APIs
Instance Launch Template APIs
Placement Group APIs
Key APIs
Security Group APIs
Network APIs
Data Types
Error Codes
Security and Compliance
CAM
Network
FAQs
Regions and Zones
Billing
Instances
Storage
Images
Server Migration
Network
Security
Operating Systems
Ops and Monitoring
CAM
NTP Service
Scenarios
Agreements
CVM Service Level Agreements
Red Hat Enterprise Linux Image Service Agreement
Public IP Service Level Agreement
Glossary

Memory Allocation Error on a Linux Instance

PDF
Focus Mode
Font Size
Last updated: 2024-01-06 17:32:18

Error Description

Log contains the error message "fork: Cannot allocate memory".



Common Causes

There are too many processes. If a new process is created after the pid_max value is reached, the error message "fork: Cannot allocate memory" will appear.

Solution

1. Check the memory utilization as instructed in Steps.
2. Check the number of processes and modify the pid_max configuration.

Steps

1. Check the memory utilization as instructed in High Memory Utilization. If the memory utilization is normal, proceed to the next step.
2. Run the following command to obtain the value of pid_max.
sysctl -a | grep pid_max
Perform corresponding operations according to the returned result:
If the returned result is as shown below, where the default value of pid_max is 32768, go to the next step.


If the error message "fork: Cannot allocate memory" is returned, run the following command to temporarily increase pid_max.
echo 42768 > /proc/sys/kernel/pid_max
Run the following command again to get the value of pid_max.
3. Run the following command to view the total number of processes.
pstree -p | wc -l
When the total number of processes has reached pid_max, a new process will cause the "fork: Cannot allocate memory" error.
Note:
You can use the ps -efL command to locate the programs for which many processes are running.
4. Change the kernel.pid_max value in the /etc/sysctl.conf configuration file to 65535 to increase the number of processes. The result should be as follows:



5. Run the following command for the configuration to take effect immediately.
sysctl -p


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback