Resident memory not released

R, Rajkumar (Raj) rajkumaradass at
Mon Aug 5 12:55:39 UTC 2019

I'm also facing this problem of memory not being released in Kubernetes, but we are using alpine image which includes musl library.  Could you please provide your thoughts in this case.


-----Original Message-----
From: nginx <nginx-bounces at> On Behalf Of fredr
Sent: Monday, August 5, 2019 4:43 PM
To: nginx at
Subject: Re: Resident memory not released

I guess you are right. The main reason I want to scale on memory rather than number of connections, is that we wouldn't have to calculate how many connections a node can handle. Eg, if we change the memory size of each node, we also have to update the automatic scaling metric, or lets say there is a new version of nginx that uses less memory per connection, then we would have to re-calibrate the scaling.

I did read up a bit on the MALLOC_CHECK_ variable, and it sound like that should not be used in production, as it reduces the overall performance.

I've also tried to compile jemalloc and load that via the LD_PRELOAD environment variable. That seems to work pretty good, memory is released/reclaimed as I would expect, but only when running nginx as root.
Not sure why it doesn't work when starting nginx as an other user though.

But I think I'll do as you suggested and scale it on number of connections for now. I'm a bit out of my depth here :) 

Peter Booth via nginx Wrote:
> I’m wondering if you are overthinking this. You said that the memory 
> was reused when the workload increased again. Linux memory management 
> is unintuitive. What would happen if you used a different metric, say 
> # active connections, as your autoscaling metric? It sounds like this 
> would behave “better”.

Posted at Nginx Forum:,285025,285109#msg-285109

nginx mailing list
nginx at

More information about the nginx mailing list