View memory warnings
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 Enterprise. So, go check your MINT data in Splunk Enterprise for recent memory warnings, which might help you fix memory issues in your mobile apps.
To work with memory warnings for MINT, initialize the Splunk MINT SDK for iOS with your API key, preferably in the beginning of your application delegates. For example:
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[Mint sharedInstance] initAndStartSessionWithAPIKey:@"API_KEY"]; // ... return true; }
The initAndStartSessionWithAPIKey method enables the memory warning monitor by swizzling the interceptor method with the didReceiveMemoryWarning delegate method of the UIViewController class. So when the OS sends a memory warning signal to the ViewController class, the warning gets logged by the MINT interceptor. The logged data is serialized into JSON data and tagged with the sourcetype "memorywarning", then sent to Splunk Enterprise.
The memory information contains the following fields:
- className
- totalMemory
- usedMemory
- wiredMemory
- activeMemory
- inactiveMemory
- freeMemory
- purgableMemory
To view this information, run a search in Splunk Web for the "mint:memorywarning" sourcetype, for example:
index=mint sourcetype="mint:memorywarning" | head 5
Here's an example result:
{ activeMemory: 9118 apiKey: 12345 appEnvironment: Testing appRunningState: Foreground appVersionCode: 1 appVersionName: 1.0 batteryLevel: -100 carrier: NA className: UINavigationController connection: WIFI currentView: GHUnitIOSViewController 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: NA uuid: fake_uid wiredMemory: 2112 }
To monitor memory warnings as they happen, you could create a real-time alert as follows:
- In Splunk Web, run this search:
index=mint sourcetype="mint:memorywarning"
- Select Save As > Alert.
- For Alert Type, click Real-time.
- Click Add Actions to select an alert action.
- Click Save.
Report user-specific data | Trace Objective-C methods |
This documentation applies to the following versions of Splunk MINT™ SDK for iOS (Legacy): 5.2.x
Feedback submitted, thanks!