-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sleepcallback.go: deregister for sleep/wake notifications during shutdown #16
Comments
Thank you for your helpful suggestions. I will try to fix them. |
@yexua I see. I think the log you provided is written by macOS and isn't related to |
我不是太懂这个,我的MBP是刚购买的,之前休眠待机耗电量几乎为1%。使用batt后,一天的休眠耗电量达到了4%左右,我不确认是否与这个有关系。 |
Is your 1% (100%->99%) or otherwise (e.g. 80%->79%)? If it 100%->99% then it is expected because that 1% about the same as 5% on other batter levels (Apple lies about battey percentage). batt shouldn't affect sleep/hibernation battery usage if you close the lid. Can you rule out other variables by uninstalling batt? |
我可以试试卸载后观察一下 |
By adding an additional info string:
it is clear that
listenNotifications()
never returns in the happy path, not even during shutdown. This means the sleep listener CFRunLoop() was simply terminated, not given a chance to cleaned up: as perpwr_mgt/IOPMLib.h
, the ports listening for sleep notifications "must" be closed by the caller. The code for cleaning up those also appeared in QA1340 listing 4. It's a memory leak.You may have to investigate passing around the CFRunLoopRef of that thread to the Go side, so as to CFRunLoopStop it during exit, after which
CFRunLoop()
returns and clean up codes can be run. Or attach another source that sets an exit flag. Doesn't seem simple.On a side note, IOPMLib.h mentions that kIOMessageSystemWillPowerOn is sent before most hardware has powered up, so if you print a log there, it would probably block until hard disks come back online. Maybe you can remove that callback.
The text was updated successfully, but these errors were encountered: