You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IOReportCreateSamples/CreateSamplesDelta return +1-retained CF objects that
were held as UnsafeRawPointer and never released — ~190KB leaked per 2s tick,
~20GB after a couple days of uptime. Release prev sample and delta each cycle.
Also: cache mach_host_self() (send-right refcount leak per call), resolve the
AppleSmartBattery service once instead of registry-matching every tick, cache
SMC key info to halve SMC syscalls, and pre-size the helper's encode buffer.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,10 @@ just release 0.5.0 # → git tag v0.5.0 && git push --tags
110
110
111
111
**IOReport dlopen:** Dylib at `/usr/lib/libIOReport.dylib`. `IOReportCopyChannelsInGroup` returns immutable → `CFDictionaryCreateMutableCopy` before subscription. Pass `subbedChannels` (not original) to `IOReportCreateSamples`. Iterate via `IOReportIterate` (block-based).
112
112
113
+
**IOReport Create-rule leaks:**`IOReportCreateSamples` / `IOReportCreateSamplesDelta` return +1-retained CF objects. Held as `UnsafeRawPointer` they're invisible to ARC — must `Unmanaged.fromOpaque(p).release()` both the old prev sample and the delta every tick, or the app leaks ~100KB/sample (20GB after a couple of days).
114
+
115
+
**Mach port refcounts:**`mach_host_self()` bumps a send-right refcount per call. Cache one `host_t` for the process lifetime instead of calling it every sample.
116
+
113
117
**IOReport channels:** Use `"CPU Energy"` / `"GPU Energy"` aggregates. For DRAM sum `DRAM*` + `DCS*` + `AMCC*`. For ANE match `ANE*`.
114
118
115
119
**proc_pidinfo visibility:**`PROC_PIDTASKALLINFO` returns 0 for system processes (uid < 500) without root. Both `PROC_PIDTASKALLINFO` and `PROC_PIDTASKINFO` fail. The helper is required for system process data.
0 commit comments