IOS app memory analysis routines and iosapp memory routines
IOS app Memory analysis routines: 2 ways to view app Memory usage in Xcode: 1. Debug Memory in navigator
This method is the easiest and most effective way to view Memory. When debugging a real machine, you can view the app Memory through Memory in Debug navigator.
Total memory is the sum of the stack memory and virtual memory (the memory occupied by OpenGL is included in the virtual memory.
Ii. Instruments
The method to start Instruments is: Product-> Profile. After a long Compilation Time, the Instruments interface appears,
In Instruments, the memory analysis tools include Activity Monitor, Allocations, and Leaks.
(1) Leaks
Leaks is a useful tool for detecting memory Leaks. When Leaks is running, the following Red Cross indicates Memory leakage.
(2) Allocations
Allocations detects the stack memory. The following VM tracker detects the virtual memory. Allocations run like
Allocations is always smaller than the Memory displayed in Debug navigator Memory because virtual Memory is not counted in Allocations. IOS regards the graphics memory occupied by OpenGL as part of the virtual memory. Refer
When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth
Some malloc memory is also included in the virtual memory. Refer to from A look at how malloc works on the Mac
(3) Activity monitor
Activity monitor depends on the overall Memory of the mobile phone. The displayed app Memory value is the same as the Memory value in Debug navigator.
Others: 1. The maximum amount of memory occupied by the app is not flushed out.
About half of the memory occupied by the machine will flash back, which is related to the system version and number of background programs.
Different channels have different requirements on memory, for example, one of the following channels
2. Why is the memory of iOS apps not leaked, but the memory cannot be downgraded?
Eg: We created about 20 goblin spine animations. At this time, the memory usage was 46 MB, and the memory usage was still 46 mb. We thought the spine memory was leaked, no memory leakage was detected by Leaks. Load and release 20 coblins repeatedly, and the memory does not exceed 48 MB, but the gross memory does not drop, but is maintained at around 46 MB?
Because (1) the image is added to the TextureCache and occupies part of the memory (2) Part of the malloc memory is included in the VM (virtual memory). In order to speed up the next malloc, although this part of memory calls free, iOS still does not recycle it. That is, the memory of some malloc mentioned above is also included in the virtual memory.
This can be tested on the mac simulator. the malloc memory is 4 MB, and the memory is free.
3. How to test app memory
(1) Use Leaks to detect memory Leaks
(2) repeatedly go to the exit function page and check whether the memory continues to rise in the Debug navigator. Memory usage continues to rise, indicating Memory leakage.