If your program is leaking memory (or CUDA memory, or file descriptors, or really any limited resource), one way to identify the problem is to use your test suite to identify specific problem APIs. I demonstrate this using pytest fixtures:
https://pythonspeed.com/articles/identifying-resource-leaks-with-pytest/