Points to Note for Memory Management in Apps That Process Large Data on iOS

Asked 1 years ago, Updated 1 years ago, 98 views

Thank you for your help.I'm sorry for the vague question, but I'm at a loss for a reply after receiving a consultation from a team member regarding the following issues.

"If you have more than 100MB of data in memory, iOS will kill the process immediately"

In order to prevent this from happening, I found out that I should take the following actions:

  • Open unnecessary views properly within the DidReceiveMemoryWarning method of the UIViewController (Do you want to replace nil?)
  • Free up unnecessary non-VC memory, such as models, in AppDelegate applicationDidReceiveMemoryWarning
  • Receive UIAapplicationDidReceiveMemoryWarningNotification Notification and take appropriate action

Note: Guidelines for Improving Memory Efficiency (https://developer.apple.com/jp/documentation/MemoryUsage.pdf)

Also, I saw the code of the app where I can see the source code on GitHub.
There were not many apps that dealt with iOS killing due to memory management.

I would appreciate it if you could let me know if there are any other measures that should be taken to prevent iOS from stopping the process.I've been writing iOS programs, and I've never encountered such cases before, and I don't often see them in introductory books.

The application that the person who consulted with me is to obtain and process images from the camera.It is necessary to have a large amount of data in memory such as image matching.

I look forward to your kind cooperation.

ios memory-management

2022-09-30 19:33

1 Answers

I'm talking about a case in which a large amount of data gets killed while processing it in a loop because I don't know what data over 100MB is and where and what it is being killed.
When a large amount of data is processed in a loop, I think it is standard to "encircle the processing in the loop with an autoreleasepool block."
I don't know if my language is ObjC or Swift, but if it's ObjC, it's

while true{
    @autoreleasepool{
        // processing
    }
}

Swift is

while true{
    autoreleasepool {
        // processing
    }
}

That's it.


2022-09-30 19:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.