i'm working on small app provides information similar coconut battery, plugs menu bar. not groundbreaking, it's more hobby me right![]()
app relies on iokit access battery information.
after launching app, uses 10 mb of memory. noticed after week of running, memory usage 100 mb, , keeps growing @ slow rate. steps taken:
enabled arc (automatic reference counting) , adjusted code accordingly. no change.
used instruments , found iokit leaked few kb per minute - app checks battery status every 10 seconds, , each time leak memory.
disabled arc, enabled garbage collection. apparently closed leaks, app down leaking 20 kb per hour. @ point small leakage occurs every few minutes, , doesn't seem correlated particular action inside program.
@ point should stop worrying... full month of running make app use 20 mb. comparison, ran coconut battery through instruments, , turns out leak same amount of memory.
below screenshot of instruments - seems indicate leak somewhere deep within iokit. i'm aware in cases it's still user error.
below relevant snipplet of method called every 10 seconds:
i should try manually release stuff (when implementing arc, have remove retain/release cycles).code:- (void) updatebatteryinfo { // go battery entry! ioregistryroot = ioregistryentryfrompath(kiomasterportdefault, "ioservice:/appleacpiplatformexpert/smb0/appleecsmbuscontroller/applesmartbatterymanager/applesmartbattery"); // read out properties tester=ioregistryentrycreatecfproperties(ioregistryroot, &properties, kcfallocatordefault,0); // set above values! cfnumbergetvalue((cfnumberref) cfdictionarygetvalue(properties, cfstr("cyclecount")), 9, &cyclecount); cfnumbergetvalue((cfnumberref) cfdictionarygetvalue(properties, cfstr("currentcapacity")), 9, ¤tcharge); // more of same commands }
attached files:
do ever release dictionary?
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment