Getting memory warning while using UIImagePickerControllerOriginalImage to get image from UIImagePickerController
I have tried to solve these problem with many ways but didn't get success.
Finally I have changed my approach and used AVCaptureSession to take picture from iPhone camera
Here is the sample code provided by Apple
https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190
All is fine now no memory leaks, performance improved, capturing processes is fast.
UIImageJPEGRepresentation - memory release issue
At the very least, there's no point in allocating and releasing the image on every trip through the loop. It shouldn't leak memory, but it's unnecessary, so move the alloc/init and release out of the loop.
Also, the data returned by UIImageJPEGRepresentation is auto-released, so it'll hang around until the current release pool drains (when you get back to the main event loop). Consider adding:
NSAutoreleasePool* p = [[NSAutoreleasePool alloc] init];
at the top of the loop, and
[p drain]
at the end. That way you'll not be leaking all of the intermediate memory.
And finally, doing a linear search for the optimal compression setting is probably pretty inefficient. Do a binary search instead.
Received memory warning in UICollectionView iOS 7
its due to assest library. Once u fetched the image using assest libary just store it in some variable and re-use that image in
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
while scrolling the collection view it will fetch the image again and again using asset libary this will cause huge memory leak.
Edit:
UIImage *img =[imageDictionary objectForKey:imageName];
if(!img)
{
NSURL *asseturl = [NSURL URLWithString:imageName];
img = [McAssetReader readImage:asseturl];
[imageDictionary setObject:img forKey:imageName];
}
where imageDictionary is the Global Dictionay for holding the image.
imageName is the url for particular image.
Related Topics
Swift 3 - How to Make Timer Work in Background
Pass Multiple Parameters to Addtarget
Combining 'And' and 'Or' Condition in Nspredicate
How to Get Memory Usage in Swift
iOS Tableview Reload and Scroll Top
How to Parse Iso 8601 Using Nsdateformatter with Optional Milliseconds Part
Custom Back Indicator Image and iOS 11
Different Cornerradius for Each Corner Swift 3 - iOS
How to Enable "Tap and Slide" in a Uislider
Open Links in Safari Instead of Uiwebview
Instagram Hooks Pre-Select Media Issue
React-Native iOS Podfile Issue with "Use_Native_Modules!"
How to Properly Group a List Fetched from Coredata by Date
How to Draw a Point Using Core Graphics
Detect App Launch from Widgetkit Widget Extension