2

Why should I use max-request to avoid memory leaks?

I have stress testing my application and memory leak has occurred, and max-request is set so memory leak is gone. Is this a required option? Or is it my fault?

shiftpsh
  • 1,926
  • 17
  • 24
변경섭
  • 23
  • 4

1 Answers1

5

During the life time your application creates objects, reads files and does lots of other staff that allocates memory. Sometimes the garbage collector can't free the memory (you can find some explanations here and here, also this one is interesting), so you have memory leaks. What the max-requests does, it just tells uWSGI to reload workers after the specified amount of managed requests, thus freeing the memory they have allocated.

Also for limiting the memory used by the workers, you can use reload-on-as and reload-on-rss options.