PDA

View Full Version : iOS - iPhone 4S / iOS 7 - Crash related to SKMaps memory usage



stevejmason
30.06.2015, 01:04
Hi,

I am using iOS Scout Maps SDK 2.5.0 and testing our application on old iPhone hardware (4S/iOS7) which we will be supporting. After panning the map around for a short period of time the application is crashing and I am seeing memory allocation issues in the console output, as below.


malloc: *** mach_vm_map(size=16777216) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
******(319,0xbaba000) malloc: *** mach_vm_map(size=16777216) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
******(319,0xa2b4000) malloc: *** mach_vm_map(size=16777216) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
******(319,0xbaba000) malloc: *** mach_vm_map(size=16777216) failed (error code=3)
*** error: can't allocate region

I have tried the following to reduce memory footprint, but memory usage is just growing with zero shrinkage (Seen in Instruments -> Allocations mode). Even if I disable mapView rendering and remove the mapView from the view hierarchy, memory is still not released!


Set maximum zoom level (9.6)
Show Street Badges = NO (Although I still see street names?)
Show House Numbers = NO
Show one ways = NO
POI display option = NONE
Map Detail = LIGHT
Using 2D instead of 3D for navigation


The following images show allocations call-stacks, showing SKMaps memory usage (particularly Font rendering. Is this street names perhaps? Can I turn rendering these off completely after a zoom limit? I thought I had disabled street badges anyway, but I still see street names).

https://drive.google.com/file/d/0B0knymIU46iwMUJKZWNfWF9hOGM/view?usp=sharing
https://drive.google.com/file/d/0B0knymIU46iwa0VSd3NVQTJfckE/view?usp=sharing
https://drive.google.com/file/d/0B0knymIU46iwZWZ1aVJEcjlWaDQ/view?usp=sharing

Please can you help us understand why the SDK is not releasing memory and leading to these crashes? This is a very urgent problem.

Many thanks.
Stephen

stevejmason
30.06.2015, 11:51
See below allocations from Instruments, clearly memory is being released (Persistent < Total Bytes), but that remaining in memory is still high. Persistently high enough to go over 150MB+ RAM and then having the malloc crashes. How is memory release being controlled?

The 20+MB of "Malloc 1MB" has 14 "TextureFont::createTexture" allocations, "Malloc 512kb" are all "std::__1::vector<float, std::__1::allocator<float> >::__push_back_slow_path<float const&>(float const&&&)"

https://drive.google.com/file/d/0B0knymIU46iwT1FENTF3MHZibjA/view?usp=sharing

stevejmason
30.06.2015, 12:57
Interesting observation #2.

Memory is released when the iOS operating system sends the application a "Low Memory Warning" notification, see first link below. The flag displayed above the graph marks when the memory warning was received. The second image below shows that the notification is in fact a low memory warning.

https://drive.google.com/file/d/0B0knymIU46iwck9iRUNuWE1QajA/view?usp=sharing
https://drive.google.com/file/d/0B0knymIU46iwcXdQQXFVSHBkZ3c/view?usp=sharing

My current (crazy) workaround to help against the app crashing too often is to schedule the low memory notification to be posted (UIApplicationDidReceiveMemoryWarningNotification) . This actually causes Skobbler to release memory in a similar fashion to the above graphs. However, the amount of memory released is dependant on how zoomed-in the map is. More memory is released when the map is zoomed further in.

This is in no way a permanent solution, and has obvious effects on rendering. (Of course this is only enabled for "old hardware").

Adela_Silvia
30.06.2015, 14:28
Hello Steve,

We've asked for help from our developers. As soon as we'll get an answer we will get back to you.

Adela_Silvia
15.07.2015, 12:36
Hi Steve,

After some further investigations- our devs haven't encounter any crashes on our demo project or on the Scout app caused by the memory issue.
Our recommendation is to analyze closer which other components might increase the memory footprint causing your app to crash.

Let us know if we can help you with other questions.

guidove
14.04.2016, 22:35
Hi Steve,

Having similar issues here on iPhone 4S and sometimes even newer devices. Did you find any solutions / workarounds yourself, other then the "crazy" one mentioned above? How often did/do you schedule the low memory notification (I'm guessing with NSTimer?)
?
Thanks and regards,
Guido