# Lua handler aborted: memory allocation error: not enough memory

**URL:** <https://www.ruby-forum.com/t/lua-handler-aborted-memory-allocation-error-not-enough-memory/221970>\
**Category:** NGINX\
**Created:** [August 7, 2012, 7:00pm UTC](https://www.ruby-forum.com/t/lua-handler-aborted-memory-allocation-error-not-enough-memory/221970 "2012-08-07T19:00:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 7, 2012, 7:00pm UTC](https://www.ruby-forum.com/t/lua-handler-aborted-memory-allocation-error-not-enough-memory/221970/1 "2012-08-07T19:00:33Z")

</div>

Hello,

Please help me to solve a problem. I use Lua to get a value from  
memcache and then jump into next nginx location and get these errors  
from time to time (ofen enaugh).

lua handler aborted: memory allocation error: not enough memory  
(lua-atpanic) Lua VM crashed, reason: not enough memory

My Lua code is simple enaugh:  
content\_by\_lua  
’  
local memcached = require “resty.memcached”;  
local memc = memcached:new();

memc:set\_timeout(500);

local connection, err = memc:connect(“…”);  
if not connection then  
return ngx.exec(“…”);  
else  
local value, flags, err = memc:get(…);  
local connection, err = memc:close()

if value  
return ngx.exec(“…”);  
else  
return ngx.exec(“…”);  
end  
end  
';

My server memory stats:  
Mem: 70G Active, 7296M Inact, 11G Wired, 3736M Cache, 9828M Buf, 806M  
Free  
Swap: 32G Total, 545M Used, 31G Free, 1% Inuse

Posted at Nginx Forum:

> **[lua handler aborted: memory allocation error: not enough memory](https://forum.nginx.org/read.php?2,229403,229403#msg-229403)**
>
> Hello, Please help me to solve a problem. I use Lua to get a value from memcache and then jump into next nginx location and get these errors from time to time (ofen enaugh). lua handler aborted: memory allocation error: not enough memory...

---

<div class="post-metadata">

**Author:** ![Yahook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9fc29f/32.png) [@Yahook](https://www.ruby-forum.com/u/Yahook)\
**Post date:** [August 8, 2012, 4:04pm UTC](https://www.ruby-forum.com/t/lua-handler-aborted-memory-allocation-error-not-enough-memory/221970/2 "2012-08-08T16:04:43Z")

</div>

I’ve found what caused this problem. I declared fastcgi\_cache\_path  
incorrectly. I allocated too much memory for keys.

Posted at Nginx Forum:

> **[Re: lua handler aborted: memory allocation error: not enough memory](https://forum.nginx.org/read.php?2,229403,229449#msg-229449)**
>
> Hello, Please help me to solve a problem. I use Lua to get a value from memcache and then jump into next nginx location and get these errors from time to time (ofen enaugh). lua handler aborted: memory allocation error: not enough memory...
