Commit f2c32c9
authored
fix: object release in macOS (#453)
* Fix object release in macOS
Previously, we would release the image data provider, but not the
image. We actually need to release the image, and not the data
provider. This is based on the CoreFoundation "Create/Copy/Get"
ownership rules: we own things that we allocate with functions with
Create or Copy in their name, but not things that have Get in their
name.
I suspect that the CGImage held a reference to its data provider,
which stored the pixel data. When we freed the data provider, we
released the pixel data, but not the CGImage structure.
Now, we're releasing the CGImage, and it releases the data provider.
Empirical testing while taking 10000 successive screenshots showed
that, once steady state was reached, the previous version was leaking
an average of about 467 bytes per screenshot on average. The new
version still leaks about 148 bytes per screenshot, although that may
not be related to macOS.
Also fixed a few function types, but those were harmless.
* Remove unneeded function declaration, and add CHANGELOG entry1 parent 201f31b commit f2c32c9
2 files changed
+23
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
| |||
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
83 | 93 | | |
84 | | - | |
85 | | - | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | | - | |
88 | | - | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| |||
197 | 207 | | |
198 | 208 | | |
199 | 209 | | |
200 | | - | |
| 210 | + | |
201 | 211 | | |
202 | 212 | | |
203 | 213 | | |
| |||
219 | 229 | | |
220 | 230 | | |
221 | 231 | | |
222 | | - | |
223 | | - | |
224 | 232 | | |
225 | 233 | | |
| 234 | + | |
226 | 235 | | |
227 | 236 | | |
228 | 237 | | |
| |||
0 commit comments