views:

86

answers:

2

Hi,

I recently inherited an iPhone app. The original developer did not understand memory management and well the app works in simlulator but not in on old iPhone (lots of crashses). Do you have any thoughts on the process by which I can save the app?

Can I utilize or create any unittest to find memory leaks and make the process 'scientific'?

Thanks

+4  A: 

Yes! Use Clang! Here is a good tutorial showing the benefits: http://iphonedevelopment.blogspot.com/2009/02/clang-static-analyzer.html

However, it should be installed if you have a newer SDK.

pkananen
On the same topic, there's also: http://www.oiledmachine.com/posts/2009/01/06/using-the-llvm-clang-static-analyzer-for-iphone-apps.html
RyanWilcox
Yes, the link I posted is actually quite old. If you're using a newer SDK, you shouldn't need to download, just select llvm as your compiler, and make sure you run the analyzer.
pkananen
You don't need to select Clang LLVM as the compiler. The analyzer works fine regardless of which compiler you're using.
Peter Hosey
+2  A: 

Since the Clang Static Analyzer is now built-in to Xcode on Snow Leopard, it's trivial to use it. Select Build -> Build & Analyze to see any memory problems Clang detects (hint: it will find pretty much all of them).

jbrennan
Better yet, turn on the “Run Static Analyzer” build setting. Then Xcode will run the analyzer on every build.
Peter Hosey
@Peter Hosey: The only problem with that is as of Xcode 3.2.1, having this setting enabled can cause problems with codesense :(
jbrennan
jbrennan: Huh? That makes no sense. Could you be more specific, or link to something that is?
Peter Hosey
@Peter Hosey: http://openradar.appspot.com/7338181
jbrennan