Introduction
In iPhone program development, memory leakage (Memory leakage) is a very prone situation because the iPhone must manage its own memory.
Nowadays, developers are mostly used to it. . Net, Java, and other development languages with a garbage collection mechanism. Therefore, you may not be used to releasing the internal storage.
Background
I have been using xcode for iPhone development for three and a half months for the first time. During this time, I have read many articles on how to find out memory leaks. However, due to the lack of basic concepts, I have gone a long way.
In iPhone development, using nslog to print retaincount directly on the console is also a method to view the internal memory leakage. However, xcode provides a more convenient leak tool for developers.
Because of its poor concept, it took a lot of time to detour when we first began to use the leak,
Therefore, write down your own experience and hope to help more developers.
How to use leak
1. As shown in, in the xcode tool column, run => "Run with perfromance tool => leak
2. Then the leak will start
3. At the same time, I will annotate [m_images release]
4. Let's take a look at the execution results!
5. this is a game project I am currently developing. Because an object will be dynamically generated or removed from the screen as the game progresses, it is in the green frame, we can see that the memory leakage does not increase in segments.
6. The list below tells us that an array is not released in cloudanimation: LoadImage.
7. Click it to display the encoding of this section.
8. Next, I will restore the annotated test code and then execute the leak again.
9. The original memory leakage is gone.
10. Some memory leaks shown in this figure are due to the fact that the music is being played and in use and will not be released. In addition, some are errors in the SDK.
Supplement: How to start instruments in xcode4