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

Поделиться
HTML-код
  • Опубликовано: 6 мар 2022
  • 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: ruclips.net/user/iOSAcademy?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 RUclips tech channel with TubeBuddy:
    www.tubebuddy.com/iosacademy
    #swift #memory #debugging

Комментарии • 59

  • @iOSAcademy
    @iOSAcademy  2 года назад +10

    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 года назад +25

    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.

  • @manni7317
    @manni7317 2 года назад +3

    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 !

  • @robinandthedog
    @robinandthedog 2 года назад +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!

  • @suryahealthcare4626
    @suryahealthcare4626 Год назад +1

    That's good 👍 need more videos in depth for expert debugging and finding memory leaks

  • @KimbrellBrad
    @KimbrellBrad 2 года назад +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!

  • @tuncayonal82
    @tuncayonal82 2 года назад +2

    Thank you so much. I was looking for this topic for long times. Best Regards...

  • @AmitBiswastunebox
    @AmitBiswastunebox 2 года назад +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.

  • @Ni7ram
    @Ni7ram Год назад +1

    loved this !

  • @yassinmziya2733
    @yassinmziya2733 2 года назад +1

    I was asked this during an interview with THE big guy. Thanks for the coverage man

  • @ignaciobrambilla7126
    @ignaciobrambilla7126 2 года назад +2

    👍👍👍👍👍 for more videos about this topic. Mostly to detect more complex leaks

  • @techpwynt348
    @techpwynt348 2 года назад +1

    Thank you so much for the video. Please make more videos on memory leaks.

  • @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 года назад +1

    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!!

  • @mak_whisk
    @mak_whisk 8 месяцев назад

    Thanks

  • @manojsomineni5979
    @manojsomineni5979 Год назад

    I am learning so much in tutorial iOS academy, thank you

  • @kironet
    @kironet 2 года назад +7

    To avoid buggy false-positives in Instruments, run on an actual device instead of the simulator.

    • @iOSAcademy
      @iOSAcademy  2 года назад +2

      Yup, the simulator is kind of annoying sometimes

  • @user-xx9lm5bd6k
    @user-xx9lm5bd6k 10 месяцев назад

    Awsome

  • @arshadshaik2578
    @arshadshaik2578 Год назад +1

    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

  • @arshadshaik2578
    @arshadshaik2578 Год назад

    Nice video, but please show how to resolve memory leaks using Instruments. Thanks

  • @TephrosXI
    @TephrosXI 8 месяцев назад

    Another video that's more in depth with a potentially real-world situation would be helpful!

  • @Jannemandevries
    @Jannemandevries 2 года назад +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.

  • @ChristopherCricketWallace
    @ChristopherCricketWallace Год назад

    how do you find a leak from a closure that's executed on the background thread?

  • @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?

  • @shurale85
    @shurale85 Год назад +2

    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 Год назад +1

      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 Год назад +1

      @@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 11 месяцев назад

      Same problem, it doesn't show memory leaks at all. I am tired of looking for a solution. Xcode 14.3

  • @kimgwangpa
    @kimgwangpa 2 года назад +2

    I prefer to implement deinit and print out. If no debug output it’s leak.

  • @shurale85
    @shurale85 2 года назад +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

  • @kyahlodi2006
    @kyahlodi2006 2 года назад +1

    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 года назад +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!

  • @f00kwhiteblackracismwarsh07
    @f00kwhiteblackracismwarsh07 2 года назад +1

    Hi,
    Can you also make Swift 5.5 course please?

    • @iOSAcademy
      @iOSAcademy  2 года назад +1

      Sure

    • @f00kwhiteblackracismwarsh07
      @f00kwhiteblackracismwarsh07 2 года назад +1

      @@iOSAcademy thank you.
      I like the way you explain things.
      I am ready to purchase this new course, looking forward to it.

  • @wlcrutch
    @wlcrutch День назад

    Wait…memory leaks? I thought Swift handled memory automatically??

  • @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 года назад +1

    Thanks