Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3882397

Browse filesBrowse files
committed
FIX: squash memory leak for redraws
1 parent 9f74ea7 commit 3882397
Copy full SHA for 3882397

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ def set_children(self, *children):
169169
# parents are destroyed, references from the children won't
170170
# keep them alive.
171171
for child in children:
172-
child._parents[id(self)] = weakref.ref(self)
172+
# pass a wek reference. The second arg is a callback for
173+
# when the weak ref is garbage collected, and will 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
173179

174180
if DEBUG:
175181
_set_children = set_children

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.