# How to debug memory leak/grow

**URL:** <https://www.ruby-forum.com/t/how-to-debug-memory-leak-grow/228427>\
**Category:** NGINX\
**Created:** [April 22, 2013, 10:38am UTC](https://www.ruby-forum.com/t/how-to-debug-memory-leak-grow/228427 "2013-04-22T10:38:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [April 22, 2013, 10:38am UTC](https://www.ruby-forum.com/t/how-to-debug-memory-leak-grow/228427/1 "2013-04-22T10:38:50Z")

</div>

in my nginx, compiled with my modules, i see that under every day usage  
(its  
on a web site , i cannot reproduce this in my lab) the memory usage of  
nginx  
grows all the time, it has many open connections (but the total number  
of  
connections is high but stays roughly the same over time) and aftert a  
week  
or so it consumes about 7GB of ram so i have to reload its processes (8  
cores = 8 nginx workers).

can somebody help me on how to debug this ? which tools you use ?  
valgrind  
did not help, even after applying the patches to nginx core for  
debugging  
with it.

Posted at Nginx Forum:

> **[how to debug memory leak/grow](https://forum.nginx.org/read.php?2,238529,238529#msg-238529)**
>
> in my nginx, compiled with my modules, i see that under every day usage (its on a web site , i cannot reproduce this in my lab) the memory usage of nginx grows all the time, it has many open connections (but the total number of connections is high...

---

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [April 22, 2013, 7:28pm UTC](https://www.ruby-forum.com/t/how-to-debug-memory-leak-grow/228427/2 "2013-04-22T19:28:09Z")

</div>

Hello!

On Mon, Apr 22, 2013 at 04:38:25AM -0400, gadh wrote:

> in my nginx, compiled with my modules, i see that under every day usage (its  
> on a web site , i cannot reproduce this in my lab) the memory usage of nginx  
> grows all the time, it has many open connections (but the total number of  
> connections is high but stays roughly the same over time) and aftert a week  
> or so it consumes about 7GB of ram so i have to reload its processes (8  
> cores = 8 nginx workers).
> 
> can somebody help me on how to debug this ? which tools you use ? valgrind  
> did not help, even after applying the patches to nginx core for debugging  
> with it.

Some tips about tracing socket leaks can by found here:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Memory leaks by itself generally don’t happen in nginx as it uses  
memory pools bound to requests for most of the allocations.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
