57

I'm starting to use Instruments-Leaks with an iPhone 3G. When I try to run the app with Instruments on the iPhone I obtain

Target failed to run: Remote exception encountered: 'Failed to get task for pid 280'

Ideas?

The only time I succeed in running the app with instruments it run very slow, I couldn't test it. What are the steps to run the app on the device searching for leaks?

Singleton
  • 3,701
  • 3
  • 24
  • 37
Sefran2
  • 3,578
  • 13
  • 71
  • 106
  • Although I can't directly help you with your issue, [here](http://mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/) is a guide that I recently found helpful. It walks you through a sample project and shows you how to use instruments to find leaks. – Stunner Dec 01 '10 at 10:41
  • Thanks. Now it runs, but it's still very slow... – Sefran2 Dec 01 '10 at 11:12
  • This may be a good tutorial, but is unhelpful with respect the error: 'Failed to get task for pid XXX' – johnnieb Feb 03 '12 at 01:47

4 Answers4

147

The solution for me was to make sure that my Profile scheme was using the "debug" and not "release" build configuration.

In Xcode 4 select Product/Edit Scheme from the top menu then click on the "profile" button on the left. On the "info" pane you will see a setting for Build Configuration- set that to "debug"

Peter Johnson
  • 3,764
  • 1
  • 23
  • 27
  • 3
    You may need to restart Xcode/clean/delete app on device (some combination of these). – Grav Dec 14 '11 at 09:22
  • 8
    This isn't really a fix right? Profiling should be on the Release build. – bogardon Feb 29 '12 at 21:48
  • 1
    wish I could tripe upvote this. I think I've come back to this about 3 times or so... Thanks! – DonnaLea Apr 20 '12 at 09:27
  • @pumpk1n would be nice if it could be on the release build, but if release builds don't have the hooks needed to attach a profiler... – Dave Cameron Jun 15 '12 at 20:23
  • @bogardon is correct. Profiling (instruments) should be done on RELEASE build. There is nothing to stop you from profiling a running release build. You can manually attach instruments after the process has started... – xaphod Sep 28 '15 at 23:00
28

This error is also thrown if you are trying to test your app on a device with a distribution profile selected. Make sure you have the correct code-sign settings for development.

rectWare
  • 291
  • 3
  • 6
  • If this is indeed correct, this is the best answer -- the above highly-rated answer will also solve the problem, but for those of us that have significant performance differences between Debug & Release profiles, it makes a difference to simply use Debug... – makdad Jan 08 '12 at 06:31
6

You CAN profile the release build on the device. What you have to do is build the release build with a developer certificate. See here.

Community
  • 1
  • 1
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
0

Instruments basically does its work by becoming the debugger for the app. If you can't run Xcode's debugger against it, then you can't run Instruments against it.

Mostly, entitlements need to be set to allow debugging.

Sometimes after using XCode to debug apps, I find I can't use Instruments until I reboot the device.

Unlike XCode, Instruments can be confused between two apps with the same name, but different bundle IDs. (Or perhaps same name and similar bundle IDs.) When I have multiple versions of an app on a device, I often have to delete the extra to get Instruments to connect to the correct app. If you have one debug build and one release build, this could be the problem.

So, delete any duplicates of your app and restart the device. (You could change the display name for release and debug build configurations.)

Walt Sellers
  • 3,806
  • 30
  • 35