an easy way to show the memory cost in your UIImageView, as a reference, to optimise app's memory usage.
Simply add Source folder with files to your project.
You can find example projects here
You just only initialize in your appDelegate.m When your App are launching. Objective-C usage
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[UIImageView showMemoryCost];
return YES;
}
Swift usage
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIImageView.showMemoryCost()
return true
}
And then, you can all the imageView memory usage in every imageView.
UIImageView and it's subclass, like: SDAnimatedImageView.
GHImageMemoryCostDetector just add a lightweight text layer in your original imageView.
The total time consuming of UIImageView image set event for 20000 times:
Testing Environment: iPhone X
System Version: iOS 13.4.1
Unit of Time : s
-
This framework only contains two files
UIImageView+MemDetector.h
UIImageView+MemDetector.m
-
Easy to use and uninstall.
-
At release mode, there will be no more any memory detection in your UIImageView.