Closed
Description
This is a similar issue to #321 #326 #328, but the cause is different
When I do this:
import pygit2, sys
repo = pygit2.Repository('libgit2')
print "refcount before: %d" % sys.getrefcount(repo)
for i in range(1,100):
len(repo.remotes)
print "refcount after: %d" % sys.getrefcount(repo)
I get this:
~/src$ python testgit.py
refcount before: 2
refcount after: 101
The root cause is the self._self_handle
in the Remote
object. Because it's an opaque reference through ffi, it seems that the python garbage collector can't detect the circular reference of the Remote to itself. That means it never gets cleaned up, and it leaks a reference to the repo in self._repo
, so that never gets cleaned up either.
Metadata
Metadata
Assignees
Labels
No labels