8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f74ea7 commit 2f0a96cCopy full SHA for 2f0a96c
lib/matplotlib/transforms.py
@@ -169,7 +169,13 @@ def set_children(self, *children):
169
# parents are destroyed, references from the children won't
170
# keep them alive.
171
for child in children:
172
- child._parents[id(self)] = weakref.ref(self)
+ # pass a weak reference. The second arg is a callback for
173
+ # when the weak ref is garbage collected to also
174
+ # remove the dictionary element, otherwise child._parents
175
+ # keeps growing for multiple draws.
176
+ ref = weakref.ref(self, lambda ref, sid=id(self),
177
+ target=child._parents: target.pop(sid))
178
+ child._parents[id(self)] = ref
179
180
if DEBUG:
181
_set_children = set_children
0 commit comments