WinCRT debug detects several memory leaks after calling py_Initialize (); py_Finalize(); functions. Most of them are garbage collector visible python's objects. I suggest to create "release" method in garbage collector which will distruct all objects in GC list without reference count checking, and call this method at the end of py_Finalize () function. I think, that it will help to avoid memory leaks after calling py_Finalize() function.
I,m trying to develop this patch now, but I'm facing the challenge (wrong ref_count or list corruption in dict objects). If I can solve it, I publish patch here.
This is a test that is supposed to run c that creates two objects, cross references them with embedded python DECREF's the objects. Then it asserts that after Py_fini is called, they have no more references because the gc should have collected them. Unfortunately the test is not failing for the right reasons and I can't figure out why.