Fatal error: runtime: out of memory

Hi Team,

When I am trying to deploy a resource using terraform it’s show’s below mentioned error, Using ArureRM

Terraform will perform the following actions:

fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x25e5a64?, 0x2030?})

As the error is saying you don’t have enough memory to run Terraform.

Are you running it in a memory constrained environment?

Hi I am not sure about it, but the statefile is in azure cloud and we are using intelliJ to perform the deployment.

This is the error details.

Terraform used the selected providers to generate the following execution

plan. Resource actions are indicated with the following symbols:

  • create

~ update in-place

  • destroy

Terraform will perform the following actions:

fatal error: runtime: out of memory

runtime stack:

runtime.throw({0x25e5a64?, 0x2030?})

/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0xc000139e00 sp=0xc000139dd0 pc=0x435e1d

runtime.sysMapOS(0xc00a800000, 0x347400000?)

/usr/local/go/src/runtime/mem_linux.go:187 +0x11b fp=0xc000139e48 sp=0xc000139e00 pc=0x41895b

runtime.sysMap(0x3e9baa0?, 0x7f0eab6e3000?, 0x42bda0?)

/usr/local/go/src/runtime/mem.go:142 +0x35 fp=0xc000139e78 sp=0xc000139e48 pc=0x418335

runtime.(*mheap).grow(0x3e9baa0, 0x1a3999?)

/usr/local/go/src/runtime/mheap.go:1459 +0x23d fp=0xc000139ee8 sp=0xc000139e78 pc=0x428e5d

runtime.(*mheap).allocSpan(0x3e9baa0, 0x1a3999, 0x0, 0x1)

/usr/local/go/src/runtime/mheap.go:1191 +0x1be fp=0xc000139f80 sp=0xc000139ee8 pc=0x4285be

runtime.(*mheap).alloc.func1()

/usr/local/go/src/runtime/mheap.go:910 +0x65 fp=0xc000139fc8 sp=0xc000139f80 pc=0x428045

runtime.systemstack()

Hi @stuart-c , Any more suggestions on this topic that would be very helpfull for me.

You need to allocate more memory to whatever system you are using to run Terraform. Is this running on your laptop or in a CI system or somewhere else?

Hi @stuart-c

I am also facing the same issue but for aws, and running from my local machine.
Does the number of resources in the state also impact this? Do we have any limits on it?
Is it nothing to do with any version issues or provider issues?

Hi @srk1195, I was facing this issue due to one curly brackets “}” missing in my code. And that was making a dead lock due to which the fatal out of memory issue occurred.
Please check you code, I have checked the provider version it’s nothing to do with this error.

Thanks