As an ios siege lion,When Apple didn't release arc (automatic memory management mechanism), almost half of our development time was spent managing this memory.Later, Apple made arc very human, although to a large extent,Help us developers save energy and time.But during our development,due to many reasons,There will still be memory leaks.Memory leaks are a serious problem.The following is a brief introduction on how to use the leaks in the instruments that come with xcode7 to detect whether our program has a memory leak and locate the memory leak code.(Analyzing memory leaks cannot detect all memory leaks.Some memory leaks are at runtime(Only generated when the user operates)
Step 1:Open the instruments that come with xcode7
As above,After successful build, jump out of instruments and select leaks option
The interface after selection is as follows:
After getting here,We have completed our preliminary preparations,Let's start the official test!
1. Select xcode to run the program (command + r) first
2. Select xcode again, press shortcut (command + control + i) to run,Leaks are now running
3. Since leaks are dynamically monitored,So we need to operate the app manually, while operating,While watching the changes in leaks, when a red cross appears,Memory leaks were detected,Click the second one in the upper right corner,Perform a pause test (may also continue the test,Pause when multiple,Processed multiple at a time). As shown:
4.The following is the positioning modification,At this point, the leaks with red pillars are selected, there is a "Tian" square underneath.
The following interface is displayed
5. Here is the most critical step,There are several checkboxes in the lower right corner of this interface.Select the invert call tree and hide system libraries (within the red circle) as follows:
Even if it's basically done here,Shown here is the memory leak code section,So it's one step left:positioning!
6. Select one of the several displayed,Double-clicking will automatically jump to the memory leak code.as the picture shows
7. Found the memory leak,Then we can modify it
- IOS common memory leaks and solutions
- IOS Example of Adjusting the Size of Pictures in Memory
- iOS reverse understanding of Block's memory model
- Detailed thoughts on the rules of iOS memory management
- Detailed ARC memory management methods in iOS application development
- Memory management in IOS
- Anatomy of Cocos2d-x memory management related operations in iOS development
- Analyze warnings and processing when iOS runs out of memory