Hi there,
Regarding the thread https://developer.apple.com/forums/thread/62310 for profiling system extension, I guess it is the content as quote below.
There are some questions as I tried:
- I have the Info.plist file as below not sure whether it is right.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<key>MallocStackLogging</key>
<string>1</string>
<key>MallocStackLoggingNoCompact</key>
<string>1</string>
</dict>
</plist>
- When I start xcode to attach to the system extension process, it says the process is running as root.
So I use sudo /Applications/Xcode.app/Contents/MacOS/Xcode
and managed to attach the system extension process, but then it seems not functional properly: dns request cannot pass through anymore (as I pass through all udp process).
Anything wrong with that?
I tried also sudo open /Applications/Xcode.app
but again it cannot attach to system extension process.
- In case with all that profiling successful, I am not sure whether it can tell where the memory leak happens.
Thanks in advance for any suggestion.
Regards
Richard
Thanks!
I’ve recently been helping a developer with this in the context of a DTS tech support incident, and I came up with a technique that, while not a full workaround, can help a lot. Here’s the highlights:
You can set environment variables in your provider by modifying its
Info.plist
. For example, adding an entry like this:
XPCService
EnvironmentVariables
FOO
bar
will set the
FOO
environment variable to
bar
.
That opens up the possibility of using memory management features enabled by environment variables, for example, those documented in the
malloc
man page. Of those,
MallocStackLoggingNoCompact
is the heavy hitter.
Once you have
MallocStackLoggingNoCompact
set, Xcode’s memory graph feature becomes super useful. To wit:
Start your provider in the normal way.
Attach to it with Xcode (Debug > Attach to Process).
In the debug pane, click the memory graph button.
You can explore the memory graph interactively with Xcode, but you can also export it to disk (File > Export Memory Graph). The resulting
.memgraph
file can be passed to a variety of command-line tools for memory analysis, including
heap
,
leaks
, and
malloc_history
(all of which have their own man page).
You can learn more about memory graphs in WWDC 2018 Session 416 iOS Memory Deep Dive.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"