简体   繁体   中英

Memory Pressure in ARC ios

I am developing an ipad app. There is only pushing view from another view no poping. At some point app is terminating due to memory pressure. I debugged using Product -- >Profile Instuments. In every view there are many allocations of images recording videos etc. and from every view around 80-100mb is getting allocated and when it reaches near 400 mb app is crashing.

Is there any way to de allocate memory in ARC when a view is disappeared ? I Tried object = Nil; but not working.

Please help me I am searching for this for last 2 days.

Work flow --> This is an app like submitting personal details First view selecting some data from a table view - then Face video record -then body video record - then room video record - and some form submission - at last uploading view

If you're loading images like:
[UIImage imageNamed:@"myImage.png"];
Then the memory for this image will not deallocated, because imageNamed: cache the image. This method is useful for showing some small icons,avatars, etc. So, if you must show many big images, then use
UIImage *myImage = [UIImage imageWithData:[[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"];
This will not cache the image and memory will deallocated when retain count will equal to 0 for that object.

Besides that, when you only push a view controller without pop it in future, then the view controller will never deallocated and will always take a place in memory until the app will not crashed/killed, or until the ViewController who holds that view controller will not deallocated.

So, always make sure that you deallocated the viewController if there is no more need of it (ie pop it if it was pushed, or dismiss it in case if it was presented modally) and then show your next view controller.

I assume that you have a navigation controller that you are pushing views onto. If so you shouldn't be pushing views if you are not popping them. Basically don't use the navigation controller and just transition between view controllers as you go through the UI. Use presentViewController, choose your transition style and make the presentation style fullscreen ought to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM