Memory on mobile devices is a shared resource, and apps that manage memory improperly run out of memory and crash. iOS manages the memory footprint of an application by controlling the lifetime of all objects using object ownership, which is part of the compiler and runtime feature called Automatic Reference Counting (ARC). When you start interacting with an object, you’re said to own that object, which means that it’s guaranteed to exist as long as you’re using it. When you’re done with the object, you relinquish ownership and if the object has no other owners, the OS destroys the object and frees up the memory. Not relinquishing ownership of an object causes memory to leak and the app to crash. ARC takes away much of the pain of memory management, but you still need to be careful with the retain cycle, global data structures and lower-level classes that don’t support ARC.
A memory warning is a signal that is sent to your app when it leaks. If the app terminates because of a memory leak, the app won’t generate a crash report. Because of that, you might not be able to find and fix the leak in your production app unless you already implemented the memory warning delegate to free up memory in the ViewController class.
To help you manage memory, the Splunk MINT SDK for iOS has a memory warning feature that collects the memory footprint and the class that received the memory warning. When an app terminates but doesn’t send a crash report, that means the app received a memory warning and sent the memory footprint to Splunk. So, go check your MINT data in Splunk Enterprise for recent memory warnings, which might help you fix memory issues in your mobile apps.
Splunk MINT SDK for IOS automatically starts to monitor for memory warnings on initialization. There is no need to do anything extra.
The memory warning information contains the following fields:
• className
• totalMemory
• usedMemory
• wiredMemory
• activeMemory
• inactiveMemory
• freeMemory
• purgableMemory
To view memory information, run a search in Splunk Web for the mint:memorywarning sourcetype, for example:
index=mint sourcetype=mint:memorywarning
Here is an example event:
{ activeMemory: 9118 apiKey: 12345 appEnvironment: Testing appRunningState: Foreground appVersionCode: 1 appVersionName: 1.0 batteryLevel: -100 carrier: NA className: LoginViewController connection: WIFI currentView: LoginViewController device: x86_64 extraData: { } freeMemory: 3040 inactiveMemory: 1511 locale: US message: Received memory warning msFromStart: 4334 osVersion: 9.3 packageName: SplunkTests platform: iOS purgableMemory: 210 remoteIP: 204.107.141.240 screenOrientation: Portrait sdkVersion: 5.0.0 session_id: 1C048628-A709-44BC-9110-25069C7FC736 state: CONNECTED totalMemory: 16384 transactions: { [+] } usedMemory: 454 userIdentifier: XXXXXXXX uuid: XXXXXXXX wiredMemory: 2112 }
To monitor memory warnings as they happen, create a real-time alert like this:
1. In Splunk Web, run this search: index=mint sourcetype=mint:memorywarning
2. Select Save As > Alert.
3. For Alert Type, click Real-time.
4. Click Add Actions to select an alert action.
5. Click Save.