mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-15 14:15:55 -06:00
[GH-ISSUE #1087] Possible memory leak in arm64ddc? #645
Labels
No labels
Status: Abandoned
arm64
beta
beta
bug
done
duplicate
enhancement
feedback needed from reporter
in progress
invalid
investigating
known Issue
monitor Issue
pull-request
translation
unable to reproduce
unreleased
x86
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/MonitorControl#645
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @krackers on GitHub (Jun 16, 2022).
Original GitHub issue: https://github.com/MonitorControl/MonitorControl/issues/1087
Originally assigned to: @krackers on GitHub.
Before opening the issue, have you...?
Describe the bug
In this file https://github.com/MonitorControl/MonitorControl/blob/main/MonitorControl/Support/Arm64DDC.swift (and possibly the intel version), I don't see any
CFRelease/IOObjectReleasecalls, despite the fact that the docs say you must release the iterator and any objects as you iterate through them. But I'm not 100% familiar with swift, does it wrap iokit to take care of these things for you?Also you should consider using
CFSTRmacro instead ofCFStringCreateWithCStringfor the string constants that are fixed, so that way you avoid any runtime allocation entirelyNote that I have not traced through instruments to see how big of an impact this is
Steps to reproduce
Expected behavior
Anything else?
No response
Environment Information (please complete the following information)
@waydabber commented on GitHub (Jun 16, 2022):
HI @krackers - yes,
all objects returned by IOKitLib should be released with this function when access to them is no longer needed.. I did not see any practical downside of skipping this in Arm64DDC even while running the app for prolonged time (the effect seems to be minimal), but still, it is proper to call IOObjectRelease on the iterators as advised. I don't think there is any special swift related mechanism is in place to do this with IOKit objects, so it's just an omission on my part (sorry about that). Thanks for pointing it out!IntelDDC does this better, but that is thanks to @reitermarkus, not me, I just took most of his code and repurposed it for MonitorControl.
Please, feel free to contribute to the code or fix/improve whatever you feel must be improved! :)
@waydabber commented on GitHub (Sep 18, 2022):
Made the proposed changes: https://github.com/MonitorControl/MonitorControl/pull/1181