Debugging memory-related errors and crashes on Xcode? Eg leaks, double release, calling methods on released objects etc

Xcode has great tools for debugging Objective-C memory errors. What are my options for debugging iOS apps written with C++ and Cocos2dx?

Here is the code that gave me an EXC_BAD_ACCESS:
@
CCFadeIn* fadeTest = CCFadeIn::create(1);
CCDelayTime* delayTest = CCDelayTime::create(12);
CCArray* testarr = CCArray::create(fadeTest, delayTest);@

I use a mix of Visual Studio Debugging, WinDbg, Valgrind, XCode and Eclipse with CDT.

XCode has some nice tools but if you use a mix of C++ tools you’ll get great results.

I didn’t have any issues debugging into C++ with xcode. What kind of issues are you having? You should just be able to set a breakpoint and dig in or let it crash and get the stack trace.

I had been similar problem

CCFadeIn* fadeTest = CCFadeIn::create(1);
CCDelayTime* delayTest = CCDelayTime::create(12);
CCArray* testarr = CCArray::create(fadeTest, delayTest);

CCArrary::create function used variadic parameter must last parameter is NULL.
CCArray::create(fadeTest, delayTest, NULL);

I had fix my problem.

Thanks for the responses, guys.

Cory, did you get Valgrind working for debugging iOS apps? I followed a blog post but all I get is “error: address doesn’t contain a section that points to a section in a object file”
http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html

C.J. Kimberlin wrote:

I didn’t have any issues debugging into C++ with xcode. What kind of issues are you having? You should just be able to set a breakpoint and dig in or let it crash and get the stack trace.

I have Xcode’s NSZombies in mind, which will tell you explicitly whenever a zombie object is released. Is this available with vanilla Xcode? Will I be able to get a friendlier error than “EXC_BAD_ACCESS”?

Thanks for the heads up, juyoung kim! The fact that the function must have NULL as the last parameter does not seem to be in the documentation: http://www.cocos2d-x.org/reference/native-cpp/d9/d2e/classcocos2d_1_1_c_c_array.html#a34643485c87a1451a6b1ddf3f147e9ad

I have created an issue for the documentation.