# Memory leaks nginx with lua memc upstream\_keepalive modules/

**URL:** <https://www.ruby-forum.com/t/memory-leaks-nginx-with-lua-memc-upstream-keepalive-modules/216903>\
**Category:** NGINX\
**Created:** [February 16, 2012, 5:53pm UTC](https://www.ruby-forum.com/t/memory-leaks-nginx-with-lua-memc-upstream-keepalive-modules/216903 "2012-02-16T17:53:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 16, 2012, 5:53pm UTC](https://www.ruby-forum.com/t/memory-leaks-nginx-with-lua-memc-upstream-keepalive-modules/216903/1 "2012-02-16T17:53:03Z")

</div>

[root@VKRT083 /home/fish]# uname -a  
FreeBSD VKRT083.local 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep  
27 18:45:57 UTC 2011  
removed\_email\_address@domain.invalid:/usr/obj/usr/src/sys/GENERIC amd64  
[root@VKRT083 /home/fish]# /usr/local/nginx/sbin/nginx -V  
nginx version: nginx/1.0.12  
built by gcc 4.2.1 20070719 [FreeBSD]  
configure arguments:  
–add-module=…/chaoslawful-lua-nginx-module-7cb4e09/  
–add-module=…/ngx\_http\_upstream\_keepalive-d9ac9ad67f45  
–add-module=…/simpl-ngx\_devel\_kit-24202b4/  
–add-module=…/agentzh-memc-nginx-module-4007350/

[root@VKRT083 /home/fish]# ps axuww|grep ngi  
– skip some strings –  
root 14076 0.0 0.0 13488 2620 ?? Is 12:45PM 0:00.02 nginx:  
master process /usr/local/nginx/sbin/nginx -c  
/usr/local/nginx/conf/new.conf (nginx)  
fish 14077 0.0 0.0 29872 7624 ?? S 12:45PM 1:31.10 nginx:  
worker process (nginx)  
fish 14078 0.0 9.1 2702512 2287312 ?? S 12:45PM 1:56.73 nginx:  
worker process (nginx)  
fish 14080 0.0 0.0 29872 7772 ?? S 12:45PM 1:30.19 nginx:  
worker process (nginx)  
fish 14081 0.0 8.6 2622640 2173000 ?? S 12:45PM 1:52.28 nginx:  
worker process (nginx)  
fish 14082 0.0 0.0 31920 9888 ?? S 12:45PM 1:40.60 nginx:  
worker process (nginx)  
fish 14083 0.0 0.0 31920 9948 ?? S 12:45PM 1:38.71 nginx:  
worker process (nginx)  
fish 14085 0.0 0.0 29872 7640 ?? S 12:45PM 1:48.66 nginx:  
worker process (nginx)  
fish 14086 0.0 5.9 1520816 1480176 ?? S 12:45PM 1:55.11 nginx:  
worker process (nginx)  
fish 14087 0.0 0.0 31920 9864 ?? S 12:45PM 1:36.69 nginx:  
worker process (nginx)  
fish 14089 0.0 0.0 29872 7752 ?? S 12:45PM 1:44.56 nginx:  
worker process (nginx)  
fish 14091 0.0 0.0 29872 6148 ?? S 12:45PM 1:47.95 nginx:  
worker process (nginx)  
fish 14094 0.0 0.0 29872 7200 ?? S 12:45PM 1:44.58 nginx:  
worker process (nginx)  
fish 14099 0.0 14.4 4895920 3620924 ?? S 12:45PM 1:50.18 nginx:  
worker process (nginx)  
fish 14103 0.0 0.0 31920 8576 ?? S 12:45PM 1:40.24 nginx:  
worker process (nginx)  
fish 14104 0.0 0.0 29872 7864 ?? S 12:45PM 1:45.71 nginx:  
worker process (nginx)  
fish 14106 0.0 0.0 29872 7824 ?? S 12:45PM 1:36.71 nginx:  
worker process (nginx)  
fish 14107 0.0 0.0 29872 6752 ?? S 12:45PM 1:46.78 nginx:  
worker process (nginx)

Posted at Nginx Forum:

> **[Memory leaks nginx with lua memc upstream\_keepalive modules/](https://forum.nginx.org/read.php?2,222489,222489#msg-222489)**
>
> \[root@VKRT083 /home/fish\]# uname -a FreeBSD VKRT083.local 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 \[root@VKRT083 /home/fish\]#...

---

<div class="post-metadata">

**Author:** ![fish\_ka\_praha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/eada6e/32.png) [@fish\_ka\_praha](https://www.ruby-forum.com/u/fish_ka_praha)\
**Post date:** [February 16, 2012, 5:54pm UTC](https://www.ruby-forum.com/t/memory-leaks-nginx-with-lua-memc-upstream-keepalive-modules/216903/2 "2012-02-16T17:54:17Z")

</div>

head of nginx.conf

[root@VKRT083 /home/fish]# cat /usr/local/nginx/conf/new.conf  
user fish;  
worker\_processes 32;

pid logs/nginxnew.pid;

#worker\_priority -5;

worker\_rlimit\_nofile 32000;

events  
{  
worker\_connections 32000;  
use kqueue;  
}

http  
{  
include mime.types;  
default\_type application/octet-stream;

```
log_format main '$remote_addr - $remote_user [$time_local]

```

$request ’  
'“$status” $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

```
server_names_hash_bucket_size 512;
sendfile on;
tcp_nopush on;
tcp_nodelay on;

gzip on;
gzip_comp_level 1;
gzip_min_length 1000;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";
gzip_types application/x-javascript text/plain application/xml;

server_tokens off;
keepalive_timeout 15;
ignore_invalid_headers on;
reset_timedout_connection on;

```

upstream backend {server 192.168.10.5:11211; keepalive 512 single;}

upstream tycoon0 {server 192.168.10.6:11111; keepalive 512 single;}

upstream tycoon1 {server 192.168.10.7:11111; keepalive 256 single;}

Posted at Nginx Forum:

> **[Re: Memory leaks nginx with lua memc upstream\_keepalive modules/](https://forum.nginx.org/read.php?2,222489,222490#msg-222490)**
>
> \[root@VKRT083 /home/fish\]# uname -a FreeBSD VKRT083.local 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 \[root@VKRT083 /home/fish\]#...

---

<div class="post-metadata">

**Author:** ![fish\_ka\_praha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/eada6e/32.png) [@fish\_ka\_praha](https://www.ruby-forum.com/u/fish_ka_praha)\
**Post date:** [February 17, 2012, 5:07am UTC](https://www.ruby-forum.com/t/memory-leaks-nginx-with-lua-memc-upstream-keepalive-modules/216903/3 "2012-02-17T05:07:38Z")

</div>

On Fri, Feb 17, 2012 at 12:52 AM, fish\_ka\_praha [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> –add-module=../simpl-ngx\_devel\_kit-24202b4/  
> –add-module=../agentzh-memc-nginx-module-4007350/

Thank you for the report. But could you show me your Lua code? Or  
could you prepare a minimized example that can reproduce this leak?

Without knowing how you actually use ngx\_lua, I’m afraid we cannot  
find the real cause here 🙂

Thanks!  
-agentzh
