59

I enabled memory checking in Xcode (Edit Scheme -> Options). I'm now getting the following when I perform on device debugging: dyld: could not load inserted library '/usr/lib/libgmalloc.dylib' because image not found. The measure was taken proactively in hopes of catching mistakes early in the cycle.

Is memory checking not valid on a device? It appears its valid since it was acknowledged and investigated according to http://lists.apple.com/archives/xcode-users/2012/Mar/msg00271.html. Also, Xcode had no complaints during compile and link. If its not valid for a device, why is Xcode inserting the library? Are there any solutions? Googling returned a few hits, but I did not see any concrete solutions.

How does one enable Xcode Guard Malloc when debugging on a device?

jww
  • 97,681
  • 90
  • 411
  • 885
  • 2
    Yes, I've had my fill and its only Wednesday :( – jww Nov 15 '12 at 13:00
  • 3
    I get the same message when enabling Guard Malloc in Xcode 4.5. The mailing list suggested to install the Lion 10.7.3 Combo update, but I'm on Mountain Lion 10.8. I'll try installing the 10.8.2 combo update (hopefully not in vain): http://support.apple.com/kb/DL1581 – CodeSmile Nov 28 '12 at 16:06

4 Answers4

67

You can't use GuardMalloc on the device.

Amit Singh
  • 2,644
  • 21
  • 20
61

To work around, I created two new Xcode schemes. One is named 'XXX Device' and does not include the malloc guards; the second is 'XXX Simulator' and does include the malloc guards.

Adding a scheme for device/simulator purposes is questionable (http://www.cocoabuilder.com/archive/xcode/303307-why-does-xcode-create-nonsensical-destinations-in-every-scheme.html). Apparently, Dave Duncan has not encountered an issue where Xcode does not do something correctly (or he does not use tools such as malloc guards).

This reeks of Cupertino software junk. +1 to Apple and its crappy QA department (if it exists) which let another bug fly free.

jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    I had forgotten that I turned this one. Lucky me, that I found this answer. I had no idea why my app just crashed right away. – Erik Engheim May 22 '13 at 14:05
  • Sucks for me, because Unity took away the ability to create XCode builds that can run on a simulator =/ . Any ideas? – cowlinator Aug 12 '14 at 19:33
11

As others answered, you can not use Enable Guard Malloc on device, but you can use it on simulator.

All 3 other memory management options, as of Xcode 7.3.1, can be used on device: Enable Malloc Scribble, Enable Malloc Guard Edges and Enable Zombie Objects.

kgaidis
  • 14,259
  • 4
  • 79
  • 93
2

Rebooting device fixed it. iOS hasn't updated. Really bad !

Ankish Jain
  • 11,305
  • 5
  • 36
  • 34