views:

261

answers:

5

Hi,

is it possible to profile C++ apps with Xcode so one gets;

  • memory leaks like with valgrind
  • possible errors before running the program

Thanks, I am very new to mac and xcode

Where can one find a good tutorial for this?

+1  A: 

Hi

This is a bit outside my current core competencies, but I've spotted a tool called Shark on my Mac which offers profiling and optimisation support. There are other Xcode tools too. But I've not yet used any of them for real. And I have no experience of valgrind on the Mac.

Not much of an answer, I know.

Regards

Mark

High Performance Mark
great thankshttp://developer.apple.com/mac/library/documentation/Performance/Conceptual/PerformanceOverview/PerformanceTools/PerformanceTools.html#//apple_ref/doc/uid/TP40001410-CH205-BCIIHAAJ
asdf
+7  A: 

You have a tool called Instruments, a free Apple tool included in XCode, that catches most of those errors.

You can find information about this tool here

pau.estalella
+2  A: 

possible errors before running the program

Xcode 3.2 now comes with static analysis tool powered by Clang, which will detect logical errors such as unreleased memory at compile time.

It is just in Build > Build and Analyze menu.

Read Apple's documentation to get more detail.

Iamamac
The Clang Static Analyzer can't deal with C++ yet.
Graham Lee
+4  A: 

Instruments is a great tool, as @pau.estalella says. Valgrind support for Mac OS X is now in the main Valgrind repository, courtesy of Greg Parker.

Graham Lee
Valgrind is indeed the greatest memory checking tool. Hopefully some day there will be DMGs available for Mac OS X.
pau.estalella
@pau.estalella You can install valgrind via MacPorts (which does have an installer that you can get via download).
Barry Wark
+3  A: 

Regarding memory leaks, run XCode and then launch Start with Performance Tool -> Leaks

Alternatively and necessarily for old pre-Panther users of XCode, it is possible to debug with guard malloc, detailed explanation in the Mac development docs, but quick walk-through is here and here

mloskot