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>
Best Answer
I had the same issue and it was solved by adding the ProcessType tag.
I had been looking at this issue from all kinds of angles comparing cpu/gpu usage, attributed system resources etc (as you must have as well) and it just wasn't apparent WHAT THE DIFFERENCE was, ie why the performance hit. In the man page it states:
You must have experienced as well that this throttling wasn't extremely apparent when looking at the process' properties.
I got this solution when I emailed the excellent folks of launchd.info about this, hooray for them. Hope this helps you.