# How to catch memory leak?

**URL:** <https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046>\
**Category:** NGINX\
**Created:** [March 3, 2011, 10:50pm UTC](https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046 "2011-03-03T22:50:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 3, 2011, 10:50pm UTC](https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046/1 "2011-03-03T22:50:11Z")

</div>

Is there any ways to catch memory leak in nginx? I run valgrind and it  
does not catch anything. I wrote module which sends sub-request to  
different location, reads response to variable. Then I check this  
variable in config file and do, or not do rewrite original url. At the  
run nginx eats about 150Mb but after day working on load it grows to  
300Mb. I run valgrind on test machine but there were not any errors.  
Looks like everything in palloc pool, which is freed after kill. From  
code it is not obvious where the leak can take place. Compilation  
–debug shows that request memory pool freed after each request.

Which techniques do you use to catch memory leak issues?

Posted at Nginx Forum:

> **[how to catch memory leak?](https://forum.nginx.org/read.php?2,180128,180128#msg-180128)**
>
> Is there any ways to catch memory leak in nginx? I run valgrind and it does not catch anything. I wrote module which sends sub-request to different location, reads response to variable. Then I check this variable in config file and do, or not do...

---

<div class="post-metadata">

**Author:** ![magz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/47e85d/32.png) [@magz](https://www.ruby-forum.com/u/magz)\
**Post date:** [March 4, 2011, 11:32am UTC](https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046/2 "2011-03-04T11:32:28Z")

</div>

Hi,

> Which techniques do you use to catch memory leak issues?

> **[GitHub - openresty/no-pool-nginx: replace nginx's pool mechanism with plain malloc &...](https://github.com/openresty/no-pool-nginx)**
>
> replace nginx's pool mechanism with plain malloc & free to help tools like valgrind

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![magz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/47e85d/32.png) [@magz](https://www.ruby-forum.com/u/magz)\
**Post date:** [March 8, 2011, 9:30pm UTC](https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046/3 "2011-03-08T21:30:29Z")

</div>

Thanks!

Posted at Nginx Forum:

> **[Re: how to catch memory leak?](https://forum.nginx.org/read.php?2,180128,181402#msg-181402)**
>
> Is there any ways to catch memory leak in nginx? I run valgrind and it does not catch anything. I wrote module which sends sub-request to different location, reads response to variable. Then I check this variable in config file and do, or not do...

---

<div class="post-metadata">

**Author:** ![magz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/47e85d/32.png) [@magz](https://www.ruby-forum.com/u/magz)\
**Post date:** [March 7, 2011, 5:32am UTC](https://www.ruby-forum.com/t/how-to-catch-memory-leak/204046/4 "2011-03-07T05:32:34Z")

</div>

On Fri, Mar 4, 2011 at 5:48 AM, magz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there any ways to catch memory leak in nginx? I run valgrind and it  
> does not catch anything.

When you run nginx with valgrind, please ensure that you set the  
following stuffs in your nginx.conf:

worker\_processes 1;  
daemon off;  
master\_process off;

Cheers,  
-agentzh
