Possible memory leak?
lists at lazygranch.com
Wed Mar 13 05:57:01 UTC 2019
I use three maps to kick out the usual clowns trying to misuse the web server. (I detect odd urls, bad user agents, and references [Links] from shady websites.) Any change to a map requires a reload. Or am I wrong?
From: nginx at nginx.org
Sent: March 12, 2019 10:44 PM
To: nginx at nginx.org
Reply-to: nginx at nginx.org
Cc: peter_booth at me.com
Subject: Re: Possible memory leak?
Perhaps I’m naive or just lucky, but I have used nginx on many contracts and permanent jobs for over ten years and have never attempted to reload canfigurations. I have always stopped then restarted nginx instances one at a time. Am I not recognizing a constraint that affects other people?
Sent from my iPhone
> On Mar 12, 2019, at 9:57 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
>> On Tue, Mar 12, 2019 at 02:09:06PM -0400, wkbrad wrote:
>> First of all, thanks so much for your insights into this and being patient
>> with me. :) I'm just trying to understand the issue and what can be done
>> about it.
>> Can you explain to me what you mean by this?
>>> you can configure system allocator to use mmap()
>> I'm not a C programmer so correct me if I'm wrong, but doesn't the Nginx
>> code determine which memory allocator it uses?
> Normally C programs use malloc() / free() functions as provided by
> system libc library to allocate memory. While it is possible for
> an application to provide its own implementation of these
> functions, this is something rarely used in practice.
>> If not can you point me to an article that describes how to do that as I
>> would like to test it?
> For details on how to control system allocator on Linux, please
> refer to the mallopt(3) manpage, notably the
> MALLOC_MMAP_THRESHOLD_ environment variable. Web version is
> available here:
> Please refer to the M_MMAP_THRESHOLD description in the same man
> page for details on what it does and various implications.
> Using a values less than NGX_CYCLE_POOL_SIZE (16k by default)
> should help to move all configuration-related allocations into
> mmap(), so these can be freed independently. Alternatively,
> recompiling nginx with NGX_CYCLE_POOL_SIZE set to a value larger
> than 128k (default mmap() threshold) should have similar
> Note though that there may be other limiting factors,
> such as MALLOC_MMAP_MAX_, which limits maximum number of mmap()
> allocations to 65536 by default.
> You can also play with different allocators by using the
> LD_PRELOAD environment variable, see for example jemalloc's wiki
>> Also, you seem to be saying that Nginx IS attempting to free the memory but
>> is not able to due to the way the OS is allocating memory or refusing to
>> release the memory. I've tested this in several Linux distros, kernels, and
>> Nginx versions and I see the same behavior in all of them. Do you know of
>> an OS or specific distro where Nginx can release the old memory allocations
>> correctly? I would like to test that too. :)
> Any Linux distro can be tuned so freed memory will be returned to
> the system, see above. And for example on FreeBSD, which uses
> jemalloc as a system allocator, unused memory is properly returned
> to the system out of the box (though can be seen in virtual
> address space occupied by the process, since the allocator uses
> madvise() to make the memory as unused instead of unmapping a
> Maxim Dounin
> nginx mailing list
> nginx at nginx.org
nginx mailing list
nginx at nginx.org
More information about the nginx