Why is an application running so slowly when started with launchctl? 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 &amp; 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.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;

  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;PROCESS_ID&lt;/string&gt;

  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;

  &lt;key&gt;KeepAlive&lt;/key&gt;
  &lt;true/&gt;

  &lt;key&gt;ThrottleInterval&lt;/key&gt;
  &lt;integer&gt;30&lt;/integer&gt;

  &lt;key&gt;Program&lt;/key&gt;
  &lt;string&gt;PATH_TO_EXECUTABLE&lt;/string&gt;

&lt;/dict&gt;
&lt;/plist&gt;


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:

&lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
  &lt;string&gt;/usr/bin/open&lt;/string&gt;
  &lt;string&gt;-W&lt;/string&gt;
  &lt;string&gt;/Applications/Safari.app&lt;/string&gt;
&lt;/array&gt;
I had the same issue and it was solved by adding the ProcessType tag. 

    &lt;key&gt;ProcessType&lt;/key&gt;
    &lt;string&gt;Interactive&lt;/string&gt;


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: 


  This optional key describes, at a high level, the intended purpose of the
       job.  The system will apply resource limits based on what kind of job it
       is. If left unspecified, the system will apply light resource limits to
       the job, throttling its CPU usage and I/O bandwidth.


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.