I'm new to iphone and objective-c development and want to ask if Clang Static Analyzer is enough for getting rid of memory leaks? I personally found the xcode "Leaks" tool rather difficult to use, besides I've seen some articles, whe开发者_运维百科re it reads that it will always show memory leaks, even if there are no any real leaks.
If I don't have any warnings from clang analyzer, does it mean that I don't have any memory leaks? Or I need to check it somehow else?
What do you think? Thank you very much.
No it is not. CSA is a static analysis tool, meaning it can only catch things that can be reasoned about at compile time. To that end it also isn't perfect, far from it. It is definitely no substitute for Instruments. CSA can however, help remind you of things in the rules, and other potential problems.
If you are using the built in Build and Analyze, you can get better results by downloading the real scan-build and turning on all checks
http://www.loufranco.com/blog/files/scan-build-better-than-build-analyze.html
But, it's still not enough. You need to check for leaks using run-time analysis. If you keep to very simple alloc/retain/release rules, you might be able to get away with it (or so close, that the Leaks tool becomes much easier to deal with).
No, the static analyser is one of the tools that is handy to have but you shouldn't rely solely on it.
Instruments and in particular the Leaks and Memory allocation tools are great ways to find leaks. The memory allocation tool can help you find leaks that leaks can't because it can show you the overall memory usage, if you notice it going up but never coming down after you finish a task you can start looking for a possible leak...
精彩评论