Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The message -bash: fork: Cannot allocate memory means Linux refused to create a new process because its memory-admission rules could not safely account for the child. It does not necessarily mean every byte of physical RAM is already occupied. On a 1 GB LAMP VPS, the usual causes are missing swap, exhausted commit headroom, Apache/PHP worker growth, oversized database buffers, a cgroup or provider limit, or a short-lived allocation spike.

Recover from the console, measure commit and swap statistics, then reduce the largest controllable consumers. Treat vm.overcommit_memory=1 as a policy change with an OOM risk, not as a universal repair. If failures continue after measured tuning, the instance has outgrown its safe capacity and needs more memory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the error actually means

Linux uses fork() to create a child process. A shell, service manager, SSH session, package tool, and many utilities all need to create processes. Before allowing the child, the kernel accounts for the address space that could be committed and applies the host’s virtual-memory policy. If admission fails, the shell reports the failure before the command can run.

That is why a command such as free -h can appear reassuring while another command cannot start. The relevant limits include committed address space, reserved memory for user processes, swap availability, container or cgroup ceilings, and transient peaks. A machine may have reclaimable pages or some “free” RAM while still being unable to promise the potential memory required by another process.

#1 Best Overall
A-Tech Server 32GB Kit (2x16GB) DDR4 2400MHz PC4-19200 ECC UDIMM 2Rx8 Dual Rank 1.2V ECC Unbuffered DIMM 288-Pin Server & Workstation RAM Memory Upgrade Modules (A-Tech Enterprise Series)
  • A-Tech RAM Memory compatible for select DDR4 Server and Workstation systems only; (*WILL NOT WORK with Desktop or Laptop Computers/PCs*)
  • 32GB RAM Kit (2 x 16GB Modules); DDR4 DIMM 288 Pin; Speeds up to 2400MHz PC4-19200 (PC4-2400T)
  • ECC Unbuffered UDIMM; 2Rx8 - Dual Rank x8; JEDEC DDR4 standard 1.2V
  • Improves system performance, workload capacity, and reduces bottlenecks by increasing memory (RAM) resources
  • Note: This memory is ECC Unbuffered and cannot be mixed with different ECC types such as ECC Registered, ECC Load Reduced, or Non-ECC Unbuffered; (Memory compatibility can vary among different system models and their installed components; please verify compatibility and follow memory channel guidelines to ensure maximum performance)

The accounting fields that matter

Read CommitLimit and Committed_AS in /proc/meminfo. In strict overcommit mode, an allocation that would push committed usage beyond the limit is rejected. Also check MemAvailable and SwapFree; they describe immediate reclaimable headroom and unused swap, not the same thing as commit capacity.

The kernel’s documented strict policy (mode 2) limits total committed address space to swap plus a configurable portion of RAM. The default RAM component is 50 percent when the ratio setting is used. The active values can be inspected with vm.overcommit_memory, vm.overcommit_ratio, or vm.overcommit_kbytes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Emergency recovery when SSH cannot run commands

Do not close your last working root session while investigating. If a new SSH login cannot spawn its shell, use an already-open session or the VPS provider’s web, serial, or recovery console. A console lets you stop a runaway service without depending on another successful fork().

Rank #2
OWC 32GB Memory RAM Kit Compatible with Synology DiskStation DS723+ DS923+
  • OWC 32GB UPGRADE: Consists of 2pcs of 16GB DDR4 2666MHz PC4-21300 CL19 2RX8 ECC SO-DIMM 1.2V 260-pin Memory Modules Compatible with Synology part numbers D4ECSO-2666-16G, D4ES01-16G
  • Compatible for Synology NAS DiskStation, RackStation, FlashStation, & NVR DVA Servers models: DS1522+, DS1618+, DS1621+, DS1621xs+, DS1819+, DS1821+, DS2419+, DS2419+II, DS2422+, DS3018xs, DS3617xs, DS3617xsII, DS3622xs+, DVA3219, DVA3221, FS1018, RS1221+, RS1221RP+, RS822+, RS822RP+
  • INCREASED PERFORMANCE: Memory Upgrades are the Most Effective and Easy Way to Boost the Performance of Your Server, Micro Server or NAS System
  • INDUSTRY LEADING: Consumer Friendly Advanced Replacement Program and Limited Lifetime Warranty, which Includes Free Tech Support by Other World Computing
  • EASY INSTALLATION: In Most Cases Installing Memory is an Easy DIY project. Watch our OWC Basic Installation Video for help.
  1. Capture a baseline before changing anything. Run free -h, swapon --show, and df -h. Then collect the key accounting values with grep -E 'MemAvailable|SwapFree|CommitLimit|Committed_AS|SwapTotal' /proc/meminfo.
  2. Find the largest resident processes. Use ps aux --sort=-%mem | head -n 20. Look for many Apache workers, PHP-FPM children, database processes, or an unexpected process multiplying rapidly.
  3. Check for kernel evidence. Review dmesg or journalctl -k for out-of-memory-killer messages. An OOM event confirms that the host reached a different failure point than a strict commit rejection, so keep both possibilities in view.
  4. Stop only the process that is clearly consuming the budget. Prefer a graceful service stop. Avoid killing the database first unless it is the confirmed runaway; an abrupt termination can damage availability and complicate recovery. If the system is wedged, use the console and stop one service at a time.
  5. Recheck after every action. Repeat the memory and process commands before starting package upgrades, compilers, backups, or multiple service restarts. Those operations can require several additional processes at once.

How to interpret the first measurements

Observation What it suggests Next action
SwapTotal: 0 and SwapFree: 0 No swap is available to provide commit headroom or absorb inactive pages. Follow the VPS provider’s supported swap-file procedure, then verify with swapon --show.
Committed_AS close to CommitLimit while vm.overcommit_memory=2 Strict admission control is near its ceiling. Review swap, the ratio or kilobyte limit, and user reserves before changing policy.
MemAvailable is low and many web workers appear in ps Apache/PHP concurrency is consuming the physical-memory budget. Cap Apache or PHP-FPM concurrency based on measured worker RSS.
Database resident memory dominates the list Buffers, caches, or connection-related allocations leave too little room for the web tier and the operating system. Reduce oversized database settings only after measuring workload impact.
Provider dashboard or cgroup reports a lower limit than the VPS plan The guest’s apparent RAM is not the effective limit for its processes. Correct the cgroup or plan limit with the provider; guest tuning cannot exceed it.
Memory looks acceptable until a restart, deployment, or backup A short-lived process spike is crossing the admission boundary. Schedule one operation at a time and leave explicit headroom for peak processes.

When missing swap is the cause—and when it is not

A 1 GB machine with no swap has little room for inactive pages or commit accounting. A troubleshooting example with Swap: 0 0 0 produced the same shell error, so absent swap is an important branch of the diagnosis. It is not proof that swap alone will cure every incident: a workload can still exceed RAM, hit a cgroup limit, or exhaust strict commit capacity after swap is added.

Create and enable swap only through the procedure supported by your VPS provider or operating-system image. Provider instructions may differ in filesystem requirements, encryption, persistence, and allowable size. After enabling it, run swapon --show and repeat the /proc/meminfo check. Confirm that SwapTotal is non-zero and that the machine can still serve requests under a normal workload.

Swap is emergency headroom, not a substitute for sustained RAM. Heavy paging increases latency, and a database or PHP pool that constantly relies on swap is still oversized for the instance. Keep enough physical memory for the kernel, filesystem cache, database, web server parent processes, and ordinary traffic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Timetec 32GB KIT (2x16GB) DDR4 2400MHz (PC4-2400T) PC4-19200 UDIMM Desktop RAM – 288-Pin 1.2V CL17 Non-ECC Unbuffered DIMM Memory Module Upgrade
  • Capacity – 32GB RAM KIT (2 x 16GB Modules) Speed up to 2400MHz Non-ECC Unbuffered 288-Pin 1.2V UDIMM.
  • Specs – Black PCB Color and Dual Rank (2Rx8).
  • Compatibility – Designed for selected DDR4 Desktop PCs and workstations that support 288-Pin UDIMM memory. NOT compatible with Laptop SODIMM slots.
  • Installation – Plug-and-Play Upgrade, Quick and Easy to Install, no expertise required (please refer to your system's manual for guidelines).
  • Warranty – All Timetec products are high-quality and rigorously tested to meet stringent standards. Backed by Timetec Limited Lifetime Warranty and professional technical support based in the United States.

Understand vm.overcommit_memory before changing it

Mode Kernel behavior Operational implication
0 Heuristic overcommit. The kernel estimates whether allocations are likely to succeed rather than applying a strict fixed ceiling.
1 Always overcommit. Allocations are admitted more freely; later pressure can end in an OOM-killer event instead of an early fork rejection.
2 Do not overcommit. Total committed address space cannot exceed swap plus the configured RAM component. This is the mode in which CommitLimit and reserve settings are especially important.

Inspect the current policy and related values before deciding: sysctl vm.overcommit_memory vm.overcommit_ratio vm.overcommit_kbytes vm.user_reserve_kbytes. Under mode 2, compare those values with CommitLimit and Committed_AS. Do not blindly run sysctl -w vm.overcommit_memory=1 simply because it makes one shell command succeed. Disabling effective admission control can postpone the error until the machine is in a more dangerous state and can increase the chance that the OOM killer terminates an important service.

Preserve recovery reserves. The kernel documentation describes a specific failure mode in which setting user_reserve_kbytes to zero allows a process to consume the reserve; subsequent attempts to execute a command then fail with the same fork: Cannot allocate memory message. If the reserve has been reduced, restore a sensible value for the distribution and workload before attempting broad tuning.

Budget the LAMP stack as one system

Apache worker growth

Prefork-style Apache configurations can make each PHP-capable worker expensive because every worker carries its own process memory. A high MaxRequestWorkers value can therefore exhaust a 1 GB host even when average traffic is modest. Measure the resident memory of representative workers, reserve memory for the operating system and database, and lower MaxRequestWorkers to a concurrency level that the measured budget can sustain. Remove modules that the application does not use, then reload Apache and watch the process count and latency.

Rank #4
A-Tech 128GB Kit (8x16GB) DDR4 2133MHz PC4-17000 ECC RDIMM 2Rx4 Dual Rank 1.2V ECC Registered DIMM 288-Pin Server & Workstation RAM Memory Upgrade Modules (A-Tech Enterprise Series)
  • A-Tech RAM Memory compatible for select DDR4 Servers & Workstation systems only; (*WILL NOT WORK with Desktop Computers, Laptop Computers, or PCs of any kind*)
  • 128GB RAM Kit (8 x 16GB Modules); DDR4 DIMM 288 Pin; Speeds up to 2133MHz PC4-17000 (PC4-2133P)
  • ECC Registered RDIMM; 2Rx4 - Dual Rank x4; JEDEC DDR4 standard 1.2V
  • Improves system performance, workload capacity, and reduces bottlenecks by increasing memory (RAM) resources
  • Note: This memory is ECC Registered and cannot be mixed with different ECC types such as ECC Unbuffered, ECC Load Reduced, or Non-ECC Unbuffered; (Memory compatibility can vary among different system models and their installed components; please verify compatibility and follow memory channel guidelines to ensure maximum performance)

Do not copy a value from a larger server. The correct limit depends on the loaded modules, PHP extensions, request mix, and the resident size of workers on this particular host.

PHP-FPM pool limits

Where the application supports it, a bounded PHP-FPM pool separates PHP worker concurrency from the web-server parent. Set pm.max_children from observed PHP worker resident memory rather than from a distribution default. A useful planning relationship is:

PHP worker budget / measured per-worker RSS ≈ safe maximum children

Best Value
Sale
CORSAIR Vengeance LPX DDR4 RAM 32GB (2x16GB) Up to 3200MHz CL16-20-20-38 1.35V Intel XMP AMD EXPO Computer Memory – Black (CMK32GX4M2E3200C16)
  • Disclaimer: Maximum Speed requires overclocking/PC BIOS adjustments. Maximum speed and performance depend on system components, including motherboard and CPU
  • Hand-sorted memory chips ensure high performance with generous overclocking headroom
  • VENGEANCE LPX is optimized for wide compatibility with the latest Intel and AMD DDR4 motherboards
  • A low-profile height of just 34mm ensures that VENGEANCE LPX even fits in most small-form-factor builds
  • A solid aluminum heatspreader efficiently dissipates heat from each module so that they consistently run at high clock speeds

Leave room for the FPM master, Apache or another web server, the database, filesystem cache, and short-lived administrative commands. After changing the pool, check whether requests queue briefly (a capacity signal) or whether workers still multiply (a configuration problem). A lower worker count may increase wait time, but it is safer than allowing the kernel to reject every new process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MySQL or MariaDB memory

Database buffers and connection-related allocations can reserve substantial memory before query workload is considered. Measure the database process’s resident set while the application is operating normally. If it dominates the 1 GB budget, reduce oversized caches or connection limits in small steps and observe query latency, hit rates, and errors after each change. Keep settings that the application genuinely requires; the goal is a measured balance, not the smallest possible database.

Changing overcommit to mode 1 does not make those allocations free. Database documentation warns that always-overcommit policy can increase the potential for memory overload and OOM-killer invocation, so database sizing and kernel policy must be evaluated together.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A safe tuning sequence

  1. Establish the limit. Record physical memory, swap, MemAvailable, CommitLimit, Committed_AS, the overcommit mode, and any provider or cgroup ceiling.
  2. Restore basic headroom. Add provider-supported swap if none exists. Remove or stop an identified runaway process, and avoid parallel maintenance jobs.
  3. Measure each tier. Record the resident size and count of Apache/PHP workers, the database, and other large services during representative traffic.
  4. Cap web concurrency. Lower Apache’s worker ceiling or PHP-FPM’s pm.max_children using the measured memory budget. Reload one service and verify that it remains healthy.
  5. Trim database settings. Reduce caches or connection limits only where measurements show they are oversized. Recheck application behavior after every change.
  6. Review strict overcommit. If mode 2 is active and committed usage is near the limit, inspect swap, ratio or kilobyte settings, and user_reserve_kbytes. Do not remove reserves to make room for ordinary workload.
  7. Test the failure trigger. Perform the deployment, restart, backup, or traffic pattern that previously caused the error while monitoring memory, swap, process counts, and kernel logs.
  8. Document the envelope. Keep the working concurrency and database settings in configuration management so a package update or image replacement does not restore unsafe defaults.

Decision tree for a 1 GB VPS

Finding Priority response Why
No swap and little available memory Add supported swap, then retest. It provides additional commit capacity and paging headroom, though not sustained RAM.
Many Apache or PHP workers Cap concurrency; use a bounded PHP-FPM pool where compatible. Worker multiplication is often the fastest controllable source of memory growth.
Database uses most resident memory Reduce buffers or connections after measuring impact. The web tier and kernel still need a guaranteed budget.
Mode 2 with Committed_AS near CommitLimit Review swap, overcommit settings, and reserves. Strict admission control is rejecting potential commitments, not merely reporting free RAM.
Failures persist after measured tuning Move to a larger VPS or managed instance with memory monitoring. The workload has exceeded the safe operating envelope of 1 GB.

When upgrading is the correct fix

Upgrade when normal traffic repeatedly drives the host into low headroom, when PHP requests queue at a safe worker limit, when database caches cannot be reduced without harming the application, or when routine deployments still trigger fork failures. A larger instance is preferable to permanently running with aggressive swapping or an always-overcommit policy that converts predictable admission failures into random process termination.

Before moving, retain the measurements that established the requirement: peak worker count, database resident memory, CommitLimit, Committed_AS, swap use, and the operation that triggers the incident. Those figures provide a defensible capacity target and help prevent migrating the same unsafe defaults to the next server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.