Problem
When you run terraform plan on a Windows system, the command fails with a fatal out of memory error. The error message in the command-line output is similar to the following.
runtime: out of memory: cannot allocate xxxxxxxxxx-byte block (xxxxxxxxxx in use)
fatal error: out of memory
goroutine 52 [running]:
runtime.throw({0x33ce057, 0xd})
<directory>/1.21.8/x64/src/runtime/panic.go:1077 +0x4d fp=0xef06fc0 sp=0xef06fac pc=0x6bd52d
runtime.(*mcache).allocLarge(0x58f0778, 0x40000000, 0x1)
<directory>/1.21.8/x64/src/runtime/mcache.go:236 +0x1c5 fp=0xef06fec sp=0xef06fc0 pc=0x698125
runtime.mallocgc(0x40000000, 0x0, 0x0)Prerequisites
- A 64-bit Windows operating system.
Cause
This error typically occurs when there is an architecture mismatch between the Terraform binary and the operating system. Running a 32-bit Terraform binary on a 64-bit Windows OS can lead to memory allocation failures during the plan operation, as the 32-bit application cannot address a sufficient amount of memory.
Solution
To resolve this issue, you must use the Terraform binary that matches your operating system's architecture.
- Navigate to the Terraform releases page.
- Download the 64-bit version of the Terraform binary for Windows (e.g.,
terraform_<version>_windows_amd64.zip). - Replace your existing 32-bit
terraform.exewith the 64-bit version.
Outcome
After replacing the binary, run the terraform plan command again. The command should now execute successfully without producing memory errors.