IOS development: the solution for the continuous increase of MKMapView map memory, iosmkmapview
Recently, a project that uses MKMapView has been modified, and the memory usage has been too high. It also increases the usage every time you drag a map and cannot be released.
After two days of troubleshooting, the final lock is to apply for memory when the self. map object is loaded, but it will not be released during the life cycle of the View.
After reading the information, I learned that removeFromSuperview can release the memory, but the map will disappear from the parent View if I remove it.
The final solution is to add two lines of code to-(void) mapView :( MKMapView *) mapView regionDidChangeAnimated :( BOOL) animated.
[Self. map removeFromSuperview]; [self. view addSubview: mapView];
When self. map is removed, the mapView is reloaded, and the two lines of code can be used to release the memory.
According to the Instruments test, memory that cannot be released can be released. The Malloc 4.00 MB in is the memory applied for the map. A total of 164 MB is applied. After MB is released, only 28 MB is needed for the map memory when the program runs smoothly.