Memory Leaks in iOS: Find, Diagnose, & Fix (2022)

  Переглядів 44,580

iOS Academy

iOS Academy

2 роки тому

In this video we will cover memory leaks in iOS apps. We will first do an example to leak some memory and then fix it. More interestingly, we will explore the Leaks Instrument to visualize leaks/memory addresses. Will additionally cover the visual memory object graph. We will work in Xcode 13.
💻 Source Code: / iosacademy
🎥 Subscribe for more: ukposts.info?su...
😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
👉🏼 Connect (personal LinkedIn) / afraz-siddiqui
🚀 Follow on LinkedIn / ios-academy
** Popular Series
Building Instagram: courses.iosacademy.io/p/build...
Building TikTok: / @iosacademy
SwiftUI for Beginners: ios-academy.teachable.com/p/s...
** Get Skillshare free for 2 Months and learn iOS
www.skillshare.com/r/user/afraz
** Manage all your investments from app earnings on Betterment!
bit.ly/3eBwlI9
** Grow your own UKposts tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy
#swift #memory #debugging

КОМЕНТАРІ: 58
@iOSAcademy
@iOSAcademy 2 роки тому
Into iOS? Lets connect! linkedin.com/in/afrazsiddiqui
@ggman8216
@ggman8216 2 роки тому
Excelent vídeo as always! One question: What is the difference between declaring the vc variable as weak to passing a weak self on to it from secondVC?
@jeffreywilkinson1471
@jeffreywilkinson1471 2 роки тому
A more in-depth discussion of Instruments specifically to debug memory leaks would be very helpful. I have a personal App I'm working on and I'm definitely retaining memory somewhere. It'd be nice to figure out what is going on and how to use Instruments.
@iOSAcademy
@iOSAcademy 2 роки тому
On my list!
@manni7317
@manni7317 2 роки тому
Finally something that makes sense, everybody used to just give definations from google and vague answers to this question, this is such an important and vast topic, now i know what to look for, Thanks man, I repect you !
@KimbrellBrad
@KimbrellBrad 2 роки тому
More in-depth coverage as well as how to cure these in SwiftUI would be very much appreciated! Great start and exposure to something that I have explored but not really focused on enough. Thanks!
@suryahealthcare4626
@suryahealthcare4626 Рік тому
That's good 👍 need more videos in depth for expert debugging and finding memory leaks
@robinandthedog
@robinandthedog 2 роки тому
top, like always, although I think I knew most, it's nice to see it come together like this for the community. Well done!
@iOSAcademy
@iOSAcademy 2 роки тому
Thanks
@yassinmziya2733
@yassinmziya2733 2 роки тому
I was asked this during an interview with THE big guy. Thanks for the coverage man
@iOSAcademy
@iOSAcademy 2 роки тому
You’re welcome
@guest9456
@guest9456 2 роки тому
Thanks a lot. that was a great and important topic. great cover. my request from you is that can you make a video about searching word from string. searching a word from textView's or SwiftUI's TextEditor's text and highlight matched ones. Like we do CMD+F? or can you guide me to it?
@CJWhitaker
@CJWhitaker 2 роки тому
Great video, as always! Would you be willing to make the following videos please? 1. Show how to implement a loading animation that shows how many photos have been retrieved from Firebase Firestore and how many are remaining (like you see with Egnyte, for example). 2. Ask user for permission to access things such as Contacts, Photo Library, Location, and their Files. Thank you for your hard work!!
@tuncayonal82
@tuncayonal82 2 роки тому
Thank you so much. I was looking for this topic for long times. Best Regards...
@iOSAcademy
@iOSAcademy 2 роки тому
You’re welcome
@AmitBiswastunebox
@AmitBiswastunebox 2 роки тому
Thanks a lot Afraz. It was a great topic with great explanation. Again you are the best. Please make some iOS debugging videos , tracing threads , understand how and where to fix and find out step by steps break points explanation. This memory leaks video covered one of them . Thanks a lot . You are doing fantastic. Good luck to you and your channel.
@iOSAcademy
@iOSAcademy 2 роки тому
Thank you!
@techpwynt348
@techpwynt348 2 роки тому
Thank you so much for the video. Please make more videos on memory leaks.
@iOSAcademy
@iOSAcademy 2 роки тому
You’re welcome
@ignaciobrambilla7126
@ignaciobrambilla7126 2 роки тому
👍👍👍👍👍 for more videos about this topic. Mostly to detect more complex leaks
@iOSAcademy
@iOSAcademy 2 роки тому
You’re welcome
@arshadshaik2578
@arshadshaik2578 Рік тому
Nice video, but please show how to resolve memory leaks using Instruments. Thanks
@TephrosXI
@TephrosXI 6 місяців тому
Another video that's more in depth with a potentially real-world situation would be helpful!
@Ni7ram
@Ni7ram Рік тому
loved this !
@iOSAcademy
@iOSAcademy Рік тому
Thanks
@arshadshaik2578
@arshadshaik2578 Рік тому
I like your videos and i have subscribed your channel. Please make different videos for each and every feature in Instruments. Like., "Time Profiler" , "Leaks", "Allocations", "Network", "Core Data" and so on.. Thanks
@ChhayaAhuja
@ChhayaAhuja 2 роки тому
My memory graph doesnt show labels like yours. Its just few shapes with arrows but no labels. How can I see label below each shape?
@manojsomineni5979
@manojsomineni5979 Рік тому
I am learning so much in tutorial iOS academy, thank you
@iOSAcademy
@iOSAcademy Рік тому
Glad to hear that!
@ChristopherCricketWallace
@ChristopherCricketWallace 10 місяців тому
how do you find a leak from a closure that's executed on the background thread?
@mak_whisk
@mak_whisk 7 місяців тому
Thanks
@iOSAcademy
@iOSAcademy 7 місяців тому
Welcome
@kironet
@kironet 2 роки тому
To avoid buggy false-positives in Instruments, run on an actual device instead of the simulator.
@iOSAcademy
@iOSAcademy 2 роки тому
Yup, the simulator is kind of annoying sometimes
@Jannemandevries
@Jannemandevries 2 роки тому
I created a little extension method that runs shortly after viewDidDisappear that checks if the VC still has a parent and/or a presentedViewController. If both are nil it's most probably a leak and shows you a warning (popup in debug builds) and sends a log to Crashlytics (release builds).
@intros1854
@intros1854 2 роки тому
Great
@Jannemandevries
@Jannemandevries Рік тому
I just finished a package named LeakedViewControllerDetector that does what I described.
@user-xx9lm5bd6k
@user-xx9lm5bd6k 8 місяців тому
Awsome
@iOSAcademy
@iOSAcademy 8 місяців тому
Thanks
@kyahlodi2006
@kyahlodi2006 2 роки тому
Hello, I always watch your video. I just want to ask for a fix or any workaround about the memory leaks in google maps sdk in ios. I can't find any working solution.
@iOSAcademy
@iOSAcademy 2 роки тому
Unfortunately you cannot easily fix a leak in someone else’s code
@kyahlodi2006
@kyahlodi2006 2 роки тому
@@iOSAcademy I see. So it is on google map sdk side? What I did is I stop the updating(CLLocationManager) after the first load, and then when saving I start again to update at the back so I can have the newest and current location. If you have a better workaround, will gladly appreciate it. Anyways, thank you very much for your reply. Really appreciate it. Keep up!
@shurale85
@shurale85 2 роки тому
One might use weak everywhere to escape leaks being not sure if it is worth to use it. I guess there are limitations, constrations and disadvantages of using weak. Can you please tell me what they are?
@iOSAcademy
@iOSAcademy 2 роки тому
I have a dedicated video on this
@shurale85
@shurale85 Рік тому
if i am not mistaken instrument did not show memory leak of custom view, did it? there were some leaks but not related to MyView instance. The reason am interested in this video I am currently investigating my project and believe there are leaks. For one of my class deinit is not called. so i tried to figure out by using instruments/leaks. However it does not show me any leaks. really strange.
@iJigarThakkar
@iJigarThakkar Рік тому
Same for me Xcode 14.2
@shurale85
@shurale85 Рік тому
@@iJigarThakkar I have investigated a project with plenty of leak since weak self is missing in every single closure. You know what, Xcode 14.1 caught no of them absolutely. What is that?..
@iJigarThakkar
@iJigarThakkar Рік тому
@@shurale85 I think there is something with either Swift 5.7 or Xcode 14, I can’t a lot to create retain cycle at all
@muradkv
@muradkv 10 місяців тому
Same problem, it doesn't show memory leaks at all. I am tired of looking for a solution. Xcode 14.3
@f00kwhiteblackracismwarsh07
@f00kwhiteblackracismwarsh07 2 роки тому
Hi, Can you also make Swift 5.5 course please?
@iOSAcademy
@iOSAcademy 2 роки тому
Sure
@f00kwhiteblackracismwarsh07
@f00kwhiteblackracismwarsh07 2 роки тому
@@iOSAcademy thank you. I like the way you explain things. I am ready to purchase this new course, looking forward to it.
@kimgwangpa
@kimgwangpa 2 роки тому
I prefer to implement deinit and print out. If no debug output it’s leak.
@iOSAcademy
@iOSAcademy 2 роки тому
Thats helpful too
@nguyendzung1997
@nguyendzung1997 Рік тому
How to diagnose memory leak flutter module integrate in native app ?
@iOSAcademy
@iOSAcademy Рік тому
Flutter memory profiling requires some external flutter tooling
@gofudgeyourselves9024
@gofudgeyourselves9024 2 роки тому
Thanks
@iOSAcademy
@iOSAcademy 2 роки тому
Youre welcome
Memory 2 - Finding and Fixing Memory Leaks (iOS, Xcode 9, Swift 4)
34:31
Mark Moeykens
Переглядів 49 тис.
How to spot and fix memory leak, retain cycle and erratic crashes
25:14
Level 1 to 100 Mystery Buttons
00:46
A4
Переглядів 8 млн
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Переглядів 11 млн
Retain Cycles: How to Detect with Instruments Profiler!
13:55
Lets Build That App
Переглядів 47 тис.
Strong vs. Weak Swift 5: What is Weak Self (Xcode 11, 2020)
16:41
iOS Academy
Переглядів 23 тис.
Weak and Unowned Self Closure Memory Leak Fixes
12:21
Lets Build That App
Переглядів 55 тис.
Apple Debugging L9 - Instruments Time Profiler
26:54
AppleProgramming
Переглядів 14 тис.
Apple Debugging L5 - Memory Graph
18:01
AppleProgramming
Переглядів 13 тис.
Swift: Dependency Injection Tutorial (2022) - iOS
24:31
iOS Academy
Переглядів 34 тис.
Swift Retain Cycle / Memory Leak Explained (iOS Interview Question)
9:05
Logan Koshenka
Переглядів 3,3 тис.
Level 1 to 100 Mystery Buttons
00:46
A4
Переглядів 8 млн