Debugging Nginx Memory Spikes on Production Servers

Dmitry Volyntsev xeioex at nginx.com
Thu Sep 21 06:45:15 UTC 2023


On 20.09.2023 20:37, Lance Dockins wrote:
> So I guess my question at the moment is whether endless memory use 
> growth being reported by njs.memoryStats.size after file writes is 
> some sort of false positive tied to quirks in how memory use is being 
> reported or whether this is indicative of a memory leak?  Any insight 
> would be appreicated.

Hi Lance,
The reason njs.memoryStats.size keeps growing is because NJS uses arena 
memory allocator linked to a current request and a new object 
representing memoryStats structure is returned every time 
njs.memoryStats is accessed. Currently NJS does not free most of the 
internal objects and structures until the current request is destroyed 
because it is not intended for a long running code.

Regarding the sudden memory spikes, please share some details about JS 
code you are using.
One place to look is to analyze the amount of traffic that goes to NJS 
locations and what exactly those location do.


More information about the nginx mailing list