Should I rely on Clang Static Analyser or Instruments?
I am working on iPhone application..
For the purpose of finding memory leaks I have started the application with the instruments which gave me lots of leaks . which i was unable to understand then in a forum somewhere I have read that the instruments gives spurious leaks sometime so I should start by the Static analysis .
Then I have used Clang Static analyser and it gave me only 7 bugs after solving that my app开发者_JAVA技巧 was bug free from the view of Static analysis .
Both analysis leaks were different .
If I still test with instruments it still gives leaks .
So my question is that should I rely on the clang Static Analyzer results or Instruments results ..
They're complimentary tools that spot problems in your code in two very different ways. You should use both.
CLANG saying "no results" doesn't mean you are bug free. It means that "CLANG" has found all the problems it can find. Just like the leaks tool cannot find all problems you consider to be leaks, because there are some things it cannot detect, and it only can find issues in the area of the app you actually tested while running it...
Think of the overall state of bugs in your application as an elephant, and the various debugging tools in XCode as a stable of blind men to try and grasp the shape of it. With enough blind men thrown at an elephant you eventually will approximate the shape of any problem you have. That's why you have to use all the tools possible.
For extra CLAG scrubbing power, set the compiler type to CLANG/LLVM. You can only compile for the simulator with that setting, but when used in conjunction with the static analyzer it can find more issues.
You shouldn't rely on one or the other, they both do very different things. Use clang to spot potential problems before you test, then use instruments to test.
Also, make sure to you instruments with both the simulator and the device. If you follow memory management best practices you'll rarely have a leak, but clang and instruments are valuable tools in tracking down leaks that might creep in.
Clang is a static analyzer which works at compile time to ensure memory management practices in the code. But Instrument is the tool for run-time analysis of device memory.
Instruments should only be used when the application is launched in an iOS device. Instrument should not be used when the application is launched in an iOS simulator.
To deliver a better iOS application we should rely on both Clang static analyzer and Instruments.
精彩评论