I've written an application in C++, using OpenGL and Cinder. When I launch the app file from the Finder, it runs nice and smoothly at 60FPS. However, when I launch it using launchctl load
the performance is terrible, the UI is sluggish and in general it runs at about half the desired FPS.
I'd like to use launchctl
to keep the application alive in the event that it crashes or needs to restart for content updates. I've read through this tutorial: http://www.launchd.info/ and found some configuration settings that might be useful, namely Data, MemoryLock, NumberOfProcesses, ResidentSetSize & Stack, but I'm not sure what values to set these at, or if they are even useful.
One interesting note, is that I've noticed that in the Activity Monitor, that the CPU usage is much lower when using launchctl
.
Here is my current plist file.
<?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>Label</key>
<string>PROCESS_ID</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ThrottleInterval</key>
<integer>30</integer>
<key>Program</key>
<string>PATH_TO_EXECUTABLE</string>
</dict>
</plist>
Update:
I figured out a work around for this problem. Rather than pointing to the executable, we can use open
and supply a path to the app file. I haven't figured out what the difference is between launching the executable directly, but it seems to remediate the problem.
Here is an example:
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-W</string>
<string>/Applications/Safari.app</string>
</array>