I know two options: 1) Build and analyze (from within Xcode) and 2) Instrument.
Are these the best tools for this job? How accurate is the construction and analysis function? I haven’t used an instrument yet, but it looked a little complicated when I tried to start.
I realized that the best way might be to study the Objective-C language itself, but I’m looking for supplementary ways to test it .
Thank you for any insights.
The instrument will look for the leaked object at runtime. So it can only find the actual problem that occurred. Therefore, in principle, you need to traverse every potential usage path in the program to capture everything. But it is in It is often very useful in practice. And it is not complicated to use. Just use the leaking instrument to start and run for a period of time, you will get a graph of memory leaks, and you can find the type of leaked objects. Then, you can ask to display the creation in the source The location of the object. Remember that you will get some secondary leaks (among which, if an object leaks, then all the objects it keeps will also leak).
Guard Malloc can also be used on the desktop , But I think it has not been used on iOS. This will cause the program to run much slower, but will crash immediately on any memory access error. So this is really helpful because usually the end of the C array or access is written Things like deallocated objects can cause errors, but they don’t necessarily do it, and sometimes cause errors in some parts of the code, which can destroy the structure used by other parts of the code and cause a completely valid code to crash.
I am a little new to Objective-C. Although I think I have a good grasp of memory management, I want to familiarize myself with the best way to test it (if possible).
I know two options: 1) build and analyze (from within Xcode) and 2) instrumentation.
Are these the best tools for this job? How accurate is the construction and analysis function? I haven’t used an instrument yet, but it looked a little complicated when I tried to start.
I realized that the best way might be to study the Objective-C language itself, but I’m looking for supplementary ways to test it .
Thank you for any insights.
The static analyzer will try to find errors in the code by inspecting the code without running the code . It’s very good at finding time when you accidentally get an allocation error. It will tell you the indisputable things that cause problems and what happens when you go beyond the normal Objective-C conventions. So if it highlights what you think Content that doesn’t cause problems is not necessarily confused-Objective-C is a combination of rules and conventions, and the analyzer will look for violations of the two.
The instrument will be at runtime Find the leaked object. So it can only find the actual problem. Therefore, in principle, you need to traverse every potential usage path in the program to capture everything. But it is often very useful in practice. And it is not complicated to use Just start it with the leak instrument, run it for a period of time, and you will get a graph of the memory leak, and you can find the type of leaked object. Then, you can ask to show where the object was created in the source. Remember, you will get some Secondary leakage (where, if an object leaks, then all the objects it keeps will also leak).
Guard Malloc can also be used on the desktop, but I think it has not been used on iOS. This Will cause the program to run much slower, but will crash immediately on any memory access error. So this is really helpful, because usually writing to the end of a C array or accessing things like deallocated objects can cause errors , But it does not necessarily do this, and sometimes causes errors in some parts of the code, which destroys the structure used by other parts of the code and causes a completely valid code to crash.