Opened 10 years ago

Closed 10 years ago

#568 closed defect (worksforme)

Possible memory leak in proxy module

Reported by: Greg Zoller Owned by:
Priority: critical Milestone: 1.7
Component: nginx-module Version:
Keywords: memory leak proxy module Cc:
uname -a: Linux gwz.dev.bottlerocketservices.com 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.4.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Description

Hello,

I'm running a stock 1.7.1 build of nginx on a Linux machine. There are a coupe other things running on the box but they are quiet--not being hit at all. Total free memory reported by top is stable over time -- nginx not runing yet (just setting a memory baseline).

I fire up nginx with proxy_pass configured as in the attached config file. Then I run the test script below and let it soak. I then observe top's reported free memory steadily decrease over time. Nothing else is happening on the box, or any other traffic to nginx except from the test script, so the only URL being exercised is the proxied one.

Test script:

#!/bin/bash
while [ true ]; do
	curl -s "http://gwz.dev.bottlerocketservices.com:9123/test/test/sample.html" > z
done

If I kill my test script memory usage immediately stabilizes and even turns positive a bit. It seems logical that somewhere in this test there is a memory leak. (The file on my proxy target 'launchpad' server that's being retrieved by the curl in my test is a simple 1K html file, and I can see from looking out the output file it is successfully being found.)

My nginx.conf is here:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    error_log    /usr/local/nginx/sbin/error.log;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       9123;
        server_name  localhost;

        location / {
            proxy_pass http://launchpad.appflighter.com;
            root   html;
            index  index.html index.htm;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

Change History (1)

comment:1 by Maxim Dounin, 10 years ago

Resolution: worksforme
Status: newclosed

Unless a size of nginx process grows, there are no reasons to assume there is a leak. Free memory as reported by top may and will decrease on any activity, in particular - due to disk caches growing. The test case you describe writes logs on each request, and free memory reported is expected to decrease.

Note: See TracTickets for help on using tickets.