Cause
The kernel allocates locked (non-swappable) memory pages when creating an io_uring instance. Locked memory stays in physical RAM to ensure high performance and low latency. This allocation fails with -ENOMEM when:
The system lacks sufficient physical memory.
The user's locked memory limit (max locked memory) is too low, even if total system memory is sufficient.
Diagnosis
Check the current user's resource limits:
ulimit -a
Find the max locked memory field in the output. This value defines the maximum amount of memory the user can lock.
Solution
Run the target program with root privileges to bypass locked memory limits.
On Elastic Compute Service (ECS) instances, escalate to root with sudo:
sudo ./your_program
In container environments, verify that the container has administrator privileges. Running a program as root inside a Docker container can still trigger -ENOMEM errors if the container lacks full host privileges. Add the --privileged flag when starting the container:
docker run --privileged=true your_image
Warning --privileged=true grants the container nearly all host privileges. Use with caution.