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

  Рет қаралды 48,221

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: kzfaq.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 KZfaq tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy
#swift #memory #debugging

Пікірлер: 60
@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
@tuncayonal82
@tuncayonal82 2 жыл бұрын
Thank you so much. I was looking for this topic for long times. Best Regards...
@iOSAcademy
@iOSAcademy 2 жыл бұрын
You’re welcome
@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
@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!
@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!!
@ignaciobrambilla7126
@ignaciobrambilla7126 2 жыл бұрын
👍👍👍👍👍 for more videos about this topic. Mostly to detect more complex leaks
@iOSAcademy
@iOSAcademy 2 жыл бұрын
You’re welcome
@techpwynt348
@techpwynt348 2 жыл бұрын
Thank you so much for the video. Please make more videos on memory leaks.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
You’re welcome
@Ni7ram
@Ni7ram Жыл бұрын
loved this !
@iOSAcademy
@iOSAcademy Жыл бұрын
Thanks
@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?
@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
@user-xx9lm5bd6k
@user-xx9lm5bd6k Жыл бұрын
Awsome
@iOSAcademy
@iOSAcademy Жыл бұрын
Thanks
@mak_whisk
@mak_whisk 10 ай бұрын
Thanks
@iOSAcademy
@iOSAcademy 10 ай бұрын
Welcome
@manojsomineni5979
@manojsomineni5979 Жыл бұрын
I am learning so much in tutorial iOS academy, thank you
@iOSAcademy
@iOSAcademy Жыл бұрын
Glad to hear that!
@TephrosXI
@TephrosXI 9 ай бұрын
Another video that's more in depth with a potentially real-world situation would be helpful!
@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?
@arshadshaik2578
@arshadshaik2578 Жыл бұрын
Nice video, but please show how to resolve memory leaks using Instruments. Thanks
@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 2 жыл бұрын
I just finished a package named LeakedViewControllerDetector that does what I described.
@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 Жыл бұрын
Same problem, it doesn't show memory leaks at all. I am tired of looking for a solution. Xcode 14.3
@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
@ChristopherCricketWallace
@ChristopherCricketWallace Жыл бұрын
how do you find a leak from a closure that's executed on the background thread?
@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!
@kimgwangpa
@kimgwangpa 2 жыл бұрын
I prefer to implement deinit and print out. If no debug output it’s leak.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thats helpful too
@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.
@nguyendzung1997
@nguyendzung1997 Жыл бұрын
How to diagnose memory leak flutter module integrate in native app ?
@iOSAcademy
@iOSAcademy Жыл бұрын
Flutter memory profiling requires some external flutter tooling
@wlcrutch
@wlcrutch Ай бұрын
Wait…memory leaks? I thought Swift handled memory automatically??
@gofudgeyourselves9024
@gofudgeyourselves9024 2 жыл бұрын
Thanks
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Youre welcome
How to spot and fix memory leak, retain cycle and erratic crashes
25:14
Strong vs. Weak Swift 5: What is Weak Self (Xcode 11, 2020)
16:41
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 25 МЛН
Gym belt !! 😂😂  @kauermotta
00:10
Tibo InShape
Рет қаралды 18 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
What's going on with Windows Laptops?
10:30
Marques Brownlee
Рет қаралды 2,6 МЛН
Debugging in Xcode 13: Tips & Tricks (2022) - iOS
14:02
iOS Academy
Рет қаралды 42 М.
Memory 2 - Finding and Fixing Memory Leaks (iOS, Xcode 9, Swift 4)
34:31
Retain Cycles: How to Detect with Instruments Profiler!
13:55
Lets Build That App
Рет қаралды 48 М.
Swift Retain Cycle / Memory Leak Explained (iOS Interview Question)
9:05
Elon Musk update on 2nd human who got Neuralink implant
9:12
Lex Clips
Рет қаралды 65 М.
WWDC23: Analyze hangs with Instruments | Apple
42:53
Apple Developer
Рет қаралды 743
Apple Debugging L5 - Memory Graph
18:01
AppleProgramming
Рет қаралды 14 М.