Resident memory not released

fredr nginx-forum at
Mon Aug 5 11:12:55 UTC 2019

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

More information about the nginx mailing list