# Custom Nginx module memleaks problem

**URL:** <https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811>\
**Category:** NGINX\
**Created:** [June 21, 2012, 3:35am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811 "2012-06-21T03:35:08Z")\
**Posts on this page:** 5\
**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:** [June 21, 2012, 3:35am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811/1 "2012-06-21T03:35:08Z")

</div>

Hi all,

Recently I write a simple Nginx module ,but when I deploy it on the  
product environment it will make the Nginx service crash as it takes too  
many memory.The main handler code is here

[http://codepad.org/2H9We02C](http://codepad.org/2H9We02C)

I’ve checked the code from time to time but still cannot solve the  
problem.And I hope someone offer me some suggestions about it.

regards

Tonny

Posted at Nginx Forum:

> **[custom Nginx module memleaks problem](https://forum.nginx.org/read.php?2,227746,227746#msg-227746)**
>
> Hi all, Recently I write a simple Nginx module ,but when I deploy it on the product environment it will make the Nginx service crash as it takes too many memory.The main handler code is here http://codepad.org/2H9We02C I've checked the

---

<div class="post-metadata">

**Author:** ![tonny.young](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tonny.young](https://www.ruby-forum.com/u/tonny.young)\
**Post date:** [June 21, 2012, 4:56am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811/2 "2012-06-21T04:56:30Z")

</div>

Hi,

On Thu, Jun 21, 2012 at 9:34 AM, tonny.young [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’ve checked the code from time to time but still cannot solve the  
> problem.And I hope someone offer me some suggestions about it.

Why not use the standard memcache module or agentzh’s memc module?  
They will not block as your module does and I believe there will be no  
memory leak either.

Regards,

---

<div class="post-metadata">

**Author:** ![tonny.young](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tonny.young](https://www.ruby-forum.com/u/tonny.young)\
**Post date:** [June 25, 2012, 2:37am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811/3 "2012-06-25T02:37:17Z")

</div>

Thanks for the suggestions.Can you explain me how my module “blocks”?

Posted at Nginx Forum:

> **[Re: custom Nginx module memleaks problem](https://forum.nginx.org/read.php?2,227746,227834#msg-227834)**
>
> Hi all, Recently I write a simple Nginx module ,but when I deploy it on the product environment it will make the Nginx service crash as it takes too many memory.The main handler code is here http://codepad.org/2H9We02C I've checked the

---

<div class="post-metadata">

**Author:** ![tonny.young](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tonny.young](https://www.ruby-forum.com/u/tonny.young)\
**Post date:** [June 25, 2012, 5:26am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811/4 "2012-06-25T05:26:42Z")

</div>

Hello!

On Mon, Jun 25, 2012 at 8:36 AM, tonny.young [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Thanks for the suggestions.Can you explain me how my module “blocks”?

All your memcached related calls from within your content handler will  
block your nginx worker processes from serving other concurrent  
requests, which essentially turns your nginx server into something  
like Apache’s prefork mpm.

Regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![tonny.young](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tonny.young](https://www.ruby-forum.com/u/tonny.young)\
**Post date:** [June 27, 2012, 6:00am UTC](https://www.ruby-forum.com/t/custom-nginx-module-memleaks-problem/220811/5 "2012-06-27T06:00:13Z")

</div>

## agentzh Wrote:

> block your nginx worker processes from serving  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Thanks for the explain.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,227746,227968#msg-227968](http://forum.nginx.org/read.php?2,227746,227968#msg-227968)
