Clearly something was "leaking" memory.
What kind of leak though?*
* blog.nelhage.com/post/three-kin…
3 Options:
- ZNC (Big pile of C++ including some weird ass 3rd party extensions for doing push notifications, probably a type-1 leak.)
- Twisted (A whole bunch of python, a type-2 or type-3 leak?)
- PyPy (I can't even begin to describe this, any type?)
By this time we'd also figured out how to reliably reproduce the memory leak locally. Running a static server and curl in a loop.
You can't use any of PyPy's tooling because it doesn't even know about the memory.
Generally to find a memory leak you have to be able to identify the kind of thing(s) that are being leaked.
The growth is perfectly linear, and the growth is only a few bytes per request.
Also the PyPy GC uses arenas where objects are grouped by size.
So now we have ~4GB of leaked objects in a core file.
To do what? Literally just look for some sort of pattern in the mess.
Every curl opened a socket, made a request, closed a socket. And here was an arena full of closed sockets.
I had configured an HTTP monitoring check. So every 5 minutes a single request would be made and a single socket would be opened then closed and leaked.
But keep in mind…
All software is fallible, sometimes the bug will be in the compiler, runtime, libc, or kernel.