Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Memory management is sometime complicate in asynchronous tasks.
Various objects need to fetch and release memory over time, in order to performed and handled asynchronous call. Async/ Await used to make many kinds of asynchronous operations easier to write.
It requires being careful when it comes to managing the memory in various objects, especially in asynchronous code(async/await)
Let me explain the implicit memory fetching with the example.
For example, we are working on downloadViewController, which downloads and shows the document.
To make our download execute lazily when our view controller is about to be displayed to the user, we’re starting that operation within our view controller’s viewDidLoad method.
viewDidLoad
Now, if we see the above code, it does not seem like there is any object fetching memory
We are expecting here, that if we start displaying our DownloadViewController, then navigate away from it before completing the downloading, that it will be successfully deallocated it. But that’s actually not the case.
DownloadViewController
As we explain earlier, implicit fetching happens when we create a Task and use await to wait the result of the asychronous task.
Now, if we want to download quite large document and we don’t want to use multiple view controllers and there operations to remain in memory if user quickly navigates between different screens.
If we want to fetch self weakly , then we have to consistently use that weak sealf reference.
Witrh the above code, our view controller will successfully deallocated.
Conclusion:
It seems technologies like Task and async/await solve the asynchronous, memory-related issues.
Task
async/await
We still have to careful how objects are fetch and retained. when performing various kinds of async calls.
async
For more clarification please read the John Sundell blog Memory management when using async/await in Swift
Hope you liked this post. If you have any other thoughts or comments you can leave your thoughts in the comment section.
For other blogs Please click here
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
It was a successful collaboration. The Mobikul team provided the client everything they needed in a timely and high-quality manner. They were very professional, reliable, and accessible during the entire process. The client also saw no room for any improvements in the vendor's performance.
Vincenzo Carrano
Administrator, Segshop
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.