Memory Leaks in Java | Issues Caused and How to Prevent | Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น •

  • @RanjitKumar-kb7zt
    @RanjitKumar-kb7zt 2 ปีที่แล้ว +7

    Finally, I got to know after many years of experience. Thanks!!!

  • @ankxy1
    @ankxy1 23 วันที่ผ่านมา +1

    Superb , thanks a lot.

    • @LazzyProgrammer
      @LazzyProgrammer  23 วันที่ผ่านมา

      Thank you so much for your feedback 🙏😊

  • @saddammd
    @saddammd 2 ปีที่แล้ว +6

    I thought these topics are only theoretical definition and it can't be visualised. Thanks for sharing your valuable knowledge.

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you, I am glad that it was helpful...

  • @DurgaShiva7574
    @DurgaShiva7574 ปีที่แล้ว +1

    one of the best videos which i have came across till date.. please keep up this good work!!

    • @LazzyProgrammer
      @LazzyProgrammer  ปีที่แล้ว +1

      Thank you so much for your feedback 😊
      Let's Keep Learning Together !!!!

  • @MrNareshProMax
    @MrNareshProMax ปีที่แล้ว +1

    thanks for sharing the knowledge in such a simple way. You are genious. Keep uploading such useful stuff.

    • @LazzyProgrammer
      @LazzyProgrammer  ปีที่แล้ว

      Thank you, I am glad that it was helpful 🙂

  • @maankhurana5814
    @maankhurana5814 6 หลายเดือนก่อน +2

    Got to learn new thing todays ... Thanks buddy

    • @LazzyProgrammer
      @LazzyProgrammer  6 หลายเดือนก่อน

      I am glad 😊 Let's keep learning

  • @utkarshvanjale749
    @utkarshvanjale749 2 ปีที่แล้ว +3

    Really helpful please come up such interesting knowledgeable videos

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you Utkarsh for your valuable feedback 🙂

  • @nikunjpatel8314
    @nikunjpatel8314 2 ปีที่แล้ว +4

    Excellent explanation with visualization. Very nice tutorial 👌 👍

  • @Rajesh-qk1ne
    @Rajesh-qk1ne 2 ปีที่แล้ว +1

    Easy to understand.... Very good explanation sir 👍👍

  • @rehbarhasan
    @rehbarhasan 27 วันที่ผ่านมา +1

    Nice explanation

    • @LazzyProgrammer
      @LazzyProgrammer  27 วันที่ผ่านมา

      Thank you for your feedback 🙏

  • @vjdreamworks2256
    @vjdreamworks2256 ปีที่แล้ว +1

    Well explained. Thanks for your efforts 🙏

    • @LazzyProgrammer
      @LazzyProgrammer  ปีที่แล้ว

      Thank you for your valuable feedback 🙏

  • @ashok55-v1h
    @ashok55-v1h 7 หลายเดือนก่อน +1

    very good content thanks a lot and all the very best.

    • @LazzyProgrammer
      @LazzyProgrammer  7 หลายเดือนก่อน

      Thank you so much Ashok :)

  • @bharathkl5229
    @bharathkl5229 10 หลายเดือนก่อน +2

    I learned a lot , thank you ❤

  • @WondersOfWandering
    @WondersOfWandering 2 ปีที่แล้ว +1

    Excellent explanation. Thank you very much!

  • @sarafarazahmadmomin1665
    @sarafarazahmadmomin1665 8 หลายเดือนก่อน +1

    Explain with perfect example

  • @pronavsandhu
    @pronavsandhu 2 ปีที่แล้ว +1

    very informative video on an underrated topic. thank you !!

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you for your feedback 🙂 Please do share the videos you like with your community as well. Let's share the knowledge.

    • @pronavsandhu
      @pronavsandhu 2 ปีที่แล้ว +1

      @@LazzyProgrammer sure

  • @dptech79
    @dptech79 2 ปีที่แล้ว +1

    Great explaination and it's very helpful

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you Durga I am glad it was helpful...

  • @syamnaidu5244
    @syamnaidu5244 ปีที่แล้ว +1

    Worth watching the video. Thank you ^_^.

  • @clarencedonovan231
    @clarencedonovan231 ปีที่แล้ว

    Amazing. Thank you so much.

  • @teeh6189
    @teeh6189 2 ปีที่แล้ว +2

    Great video with easy to understand explanation. I have a question. I checked my hprof heap dump as I thought my application was causing memory leaks, but it turns out most of the memory is consumed by byte, char and Strings which are not from my application. How do I fix or avoid memory leaks in that case? Your response will be highly appreciated. Thanks

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you for your support and feedback 😊
      For the issue which you are currently facing. As there is no user defined classes which are causing the issue. You need to check the over usage of Strings in your application. Are you doing a lot of String manipulation? In such cases you may need to use StringBuilder/StringBuffer depending on the nature of your application (Single Threaded/Multi Threaded). Also, look for the connection objects and buffers, they must be closed after use. I will recommend to use try-with-resources if you are using Java 1.7 and above.

  • @peterg76yt
    @peterg76yt ปีที่แล้ว +1

    A static field, by itself, is not a memory leak. It's only a memory leak if memory is allocated but not released when no longer needed. If you need a list of doubles for the lifetime of the program, then keeping the data in a static field is an appropriate design. If at some point in the program execution they are no longer needed, just call List::clear.

  • @SohailKhan-pu2oi
    @SohailKhan-pu2oi 2 ปีที่แล้ว

    Great Sir! keep sharing such awesome tutorials.

  • @kishordige9721
    @kishordige9721 ปีที่แล้ว +1

    Was helful

  • @poonamjadhao4990
    @poonamjadhao4990 2 ปีที่แล้ว

    Nicely explain. Very useful.

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      Thank you Poonam, I am glad that it was useful...

  • @rocastone1349
    @rocastone1349 2 ปีที่แล้ว +1

    super cool!!!

  • @waitseego
    @waitseego 2 หลายเดือนก่อน

    Hi thanks for sharing this knowledge. Could you explain if we got static methods not variables. Will it still keep the objects we create inside or passed as org for ever?

    • @LazzyProgrammer
      @LazzyProgrammer  2 หลายเดือนก่อน

      I believe objects passed as arguments or created inside static method will get out of scope and ready to be garbage collected as soon as the static method execution is complete.

  • @JorgetePanete
    @JorgetePanete 2 ปีที่แล้ว +2

    Correction: in java 9+, do not avoid string concatenation if the whole string is computed on a single operation (i.e. not in a loop), the compiler and runtime know enough for it to be optimal

  • @pravinjain2834
    @pravinjain2834 ปีที่แล้ว +1

    Why the populate method is not declared static, since it is only using static member?
    In that case to populate the list we will not need to create the object of the class.
    And when the list is no longer needed then it could be set to null, to let the garbage collector reclain it. It would not need the unloading of the class in such a case.

    • @LazzyProgrammer
      @LazzyProgrammer  ปีที่แล้ว

      Yes you can do it that way also, there should not be any issue. But to test the non static list anyway you have to make the populate method as non static.

    • @pravinjain2834
      @pravinjain2834 ปีที่แล้ว +1

      @@LazzyProgrammer Agreed, The idea is that whereever a method can be written as static(not dependent on instance), it should be declared static and invoked without using an instance.

  • @Rudar263
    @Rudar263 2 ปีที่แล้ว

    Awesome

  • @AmNotLegend
    @AmNotLegend ปีที่แล้ว

    how to run it from a MAC os

    • @LazzyProgrammer
      @LazzyProgrammer  ปีที่แล้ว

      Hello Yichun,
      You can download and install .dmg from visual vm's website for running it on Mac.

  • @nupurgulati9433
    @nupurgulati9433 2 ปีที่แล้ว

    This is very useful 👍

    • @LazzyProgrammer
      @LazzyProgrammer  2 ปีที่แล้ว

      I am glad it was useful. Thanks for sharing your valuable feedback 😊

  • @JorgetePanete
    @JorgetePanete 2 ปีที่แล้ว +1

    Soon to be a correction: the finally block is most of the time replaced by the try-with-resources, and the finally block will be removed in some future java release