The problem is that you are not freeing the output buffers of the task. You cannot simply run the task and waitUntilDone if the task also did not produce an extremely small amount of data.
waitUntilDone will obviously not work with a task that never waitUntilDone .
For a task that emits any amount of output, you need to configure it so that the output is read as it is created. Typically, you use readInBackgroundAndNotify or an option in it.
In any case, the top of the class description for NSTask has both links to a conceptual guide, and a number of examples that cover this.
source share