Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AnxiousHoliday/MimirMemoryLogger
🔥 A fast & easy way to save snapshots of memory heap to disk on iOS devices and then prettify and sort the snapshot json files accordingly using a simple python script!
https://github.com/AnxiousHoliday/MimirMemoryLogger
disk framework heap ios json-snapshots logger logging logs memory memory-heap memory-snapshots mimir objective-c oom python-script snapshot stack swift
Last synced: about 2 months ago
JSON representation
🔥 A fast & easy way to save snapshots of memory heap to disk on iOS devices and then prettify and sort the snapshot json files accordingly using a simple python script!
- Host: GitHub
- URL: https://github.com/AnxiousHoliday/MimirMemoryLogger
- Owner: AnxiousHoliday
- License: mit
- Created: 2020-09-28T19:42:39.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-11T22:19:31.000Z (about 4 years ago)
- Last Synced: 2024-10-19T05:15:17.970Z (2 months ago)
- Topics: disk, framework, heap, ios, json-snapshots, logger, logging, logs, memory, memory-heap, memory-snapshots, mimir, objective-c, oom, python-script, snapshot, stack, swift
- Language: Objective-C
- Homepage:
- Size: 689 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Heap logging framework for iOS (Memory snapshots)
## Overview
MimirMemoryLogger is a memory logging framework (Swift & Objective-C) that is intended to help developers better debug memory issues when connecting the device to Xcode is not possible.What this framework does is basically takes a snapshot of the iOS device's heap and saves it to disk as a json file. This json file can then be used alongside a python script i wrote (please don't judge my python code 😅) that loops over all the memory instances in the json file and sorts them accordingly in terminal.
## How it works
1. Trigger saving memory heap snapshot whenever you want (e.g when the app receives `applicationDidReceiveMemoryWarning`)
2. MimirMemoryLogger saves the memory snapshot to disk
3. User sends memory snapshot (automatically or manually) to developer
4. Developer runs python script with the json memory snapshot as a parameter
5. Script shows the memory heap usage of your app which allows the developer to look into the reason of heavy memory usage### Python Script Samples
These are 2 samples of what the result of using the heap snapshot json file with the python script (included in the repo)![python script mimir MimirMemoryLogger](./Resources/python-script-sample1.png)
![python script mimir MimirMemoryLogger](./Resources/python-script-sample2.png)
Samples of json memory snapshots are in ./Resources/snapshot-samples
# Usage - Swift
## Taking snapshot of memory
```swift
import MimirMemoryLogger // Do not forget thisMimirMemoryLogger.saveCurrentSnapshotToFile { (url) -> (Void) in
if let url = url {
print("Memory snapshot location: \(url.absoluteString)")
}
}
```## Getting previously saved snapshots
```swift
if let urls = MimirMemoryLogger.getSavedSnapshots() {
print("URLS of all saved snapshots: \(urls)")
}
```## Customization
You can set the maximum number of snapshots that persist on disk. Default is 5```swift
MimirMemoryLogger.maxNumberOfSnapshots = 3
```If you want more details on what is happening while saving and getting snapshots, you can set verbose to true in MimirMemoryLogger. This will print to console added details and information such as time it takes to save a snapshot or if there are any errors.
```swift
MimirMemoryLogger.verbose = true
```# Usage - Python Script
## Viewing the json snapshots in terminal
This project relies on one Python script that sorts and prettifies the results in a json snapshot file just like in the sample images at the beginning of this readme. This script is located here: `./PythonScripts/MimirMemoryLogger.py`This script was written with the help of [BeautifulTable](https://github.com/pri22296/beautifultable).
Just call this script with the json file as an argument (samples of json snapshots are in ./Resources/snapshot-samples).
For example:
```bash
python3 MimirMemoryLogger sample-snapshot.json
```## Notes
This framework is still in the early phases and will keep evolving.
If you use this framework and happen to like it, feel free to let me know 😊
## Installation
Mimir is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```swift
pod 'MimirMemoryLogger'
```## Author
Amer Eid, [email protected]
## License
Mimir is available under the MIT license. See the LICENSE file for more info.