Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS 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 220.127.116.11 release ready!
Owner and Founder. Opencart
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.
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.
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.
It seems technologies like Task and async/await solve the asynchronous, memory-related issues.
We still have to careful how objects are fetch and retained. when performing various kinds of async calls.
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*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.