Commit 8864085
committed
Don't save parents in LayoutGrid
Internally, the parent is only used in `__init__`, so doesn't need to be
saved as an attribute. Externally, the constrained layout code needs the
parent only for subfigure margins, but we have the parent gridspec
available directly to use.
The `LayoutGrid` stores its children in a NumPy array, and saving the
parent causes a reference cycle. Apparently having one reference in a
C-level NumPy array causes Python to not realize it can garbage collect
the cycle, causing all `LayoutGrid` and its children to leak.1 parent b0d47f0 commit 8864085
2 files changed
+8
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
| 350 | + | |
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
352 | 354 | | |
353 | 355 | | |
354 | 356 | | |
355 | | - | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | | - | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
64 | 61 | | |
65 | | - | |
| 62 | + | |
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
| |||
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
103 | | - | |
| 100 | + | |
104 | 101 | | |
105 | 102 | | |
106 | 103 | | |
| |||
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
133 | | - | |
| 130 | + | |
134 | 131 | | |
135 | 132 | | |
136 | 133 | | |
137 | | - | |
| 134 | + | |
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
| |||
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
171 | | - | |
| 168 | + | |
172 | 169 | | |
173 | 170 | | |
174 | 171 | | |
175 | 172 | | |
176 | | - | |
177 | 173 | | |
178 | 174 | | |
179 | 175 | | |
| |||
0 commit comments