C Dynamic Memory Debugging with Valgrind

Sdílet
Vložit
  • čas přidán 4. 02. 2015
  • Demo of how to use the free valgrind tool under Linux to debug dynamic memory access problems in a C program. Shows how to install and run the tool, interpret its output, and fix errors. Video also shows a number of common dynamic memory programming errors with C.

Komentáře • 81

  • @TomGrubbe
    @TomGrubbe Před 9 lety +30

    One of the better valgrind tutorials. Nicely done.

    • @danteeep
      @danteeep Před 4 lety

      it's great. For those of you guys that dont get the line of the error or mem leak then follow this: compile it with "-g" . gcc -g test.c -o test and then valgrind --track-origins=yes --leak-check=full ./test

  • @argonlaser2775
    @argonlaser2775 Před 6 lety +4

    One of the best valgrind tutorials. Covers pretty much most base cases. Neatly explained.

  • @shivajithmutteal4595
    @shivajithmutteal4595 Před 8 lety

    Great Debugging Tutorial with Valgrind!

  • @dorivalneto4519
    @dorivalneto4519 Před 4 lety

    The best tutorial I've ever seen.

  • @markoveniger4533
    @markoveniger4533 Před 6 lety +72

    I think that in test 2 line 20 there is a problem with the allocation. You are allocating an array of 5 pointers instead of 5 long longs, it should be *weights in the brackets. Valgrind can't detect it because the size of long long is 8 bytes which is the same as the pointer size on a 64bit machine(In most cases). If you would swap that long long out with an int it would fail probably.

  • @MrVicander99
    @MrVicander99 Před 8 lety +27

    You're a hero.

  • @DC-rk6xf
    @DC-rk6xf Před 6 lety +2

    Thanks for this instructive video.

  • @PietroSantagati
    @PietroSantagati Před 8 lety

    Basic examples, but very useful to approach Valgrind features.

  • @DavidGiordana
    @DavidGiordana Před 6 lety

    Excellent, this was so helpful. Thanks a lot

  • @sousra5080
    @sousra5080 Před rokem

    Thanks for this amazing video, my friend!

  • @strawberryPlasma
    @strawberryPlasma Před 6 lety +3

    thank you! it was very helpful :)

  • @arthurs6405
    @arthurs6405 Před 5 měsíci

    Thank you very much. That was very well explained. Good job. I am assuming that you are an professor and thus I can believe that your students are benefiting from paying the excessive tuition being charged today.

  • @jphamzz
    @jphamzz Před 7 lety +1

    thank you thank you! for these tips!

  • @tsnp423
    @tsnp423 Před 5 lety

    You're fantastic dude...

  • @filipeboaventura127
    @filipeboaventura127 Před 8 lety

    That was very helpfull. Thank you!

  • @kafeel595
    @kafeel595 Před 4 lety

    Very Good Lecture ...Easy to understand by different types of Problem...i request you to please do one lecture on Makefile. types of makefile how to implement...

  • @mahend
    @mahend Před 7 lety

    amazing tutorial.. Thank you so much

  • @danteeep
    @danteeep Před 4 lety

    it's great thx for that. For those of you guys that dont get the line of the error or mem leak then follow this: compile it with "-g" . gcc -g test.c -o test and then valgrind --track-origins=yes --leak-check=full ./test

  • @shirleyachara3809
    @shirleyachara3809 Před 3 lety

    Great lecture, thanks.

  • @rajendra332
    @rajendra332 Před 8 lety

    Thanks for the Tutorial

  • @SandorGonzalez
    @SandorGonzalez Před 6 lety

    Nice video! Thanks. Btw r u a Canuck? :)

  • @Casowsky
    @Casowsky Před 8 lety

    Very helpful... thanks!

  • @IamFuU
    @IamFuU Před 9 lety

    thank you! that was helpful.

  • @MediaFilter
    @MediaFilter Před 9 lety +1

    Nice. Do you think you might do a hands-on video on the topic of interpreting kcachegrind views to improve performance, based on outputs from callgrind, cachegrind, helgrind?

  • @arulprakasan1697
    @arulprakasan1697 Před 2 lety

    Very informative Thank you !!!

  • @jenmanzella1948
    @jenmanzella1948 Před 5 lety +2

    This is really helpful. Thank you for posting it! I'm currently debugging my unit test and trying to trace an error similar to what came up in your fourth test. Would it be okay if I messaged you a few questions about valgrind? I could really use some advice. :)

  • @user-gr5do8nk7e
    @user-gr5do8nk7e Před 7 lety +3

    *THANKS A LOT !!!!*

  • @aidan3651
    @aidan3651 Před 7 lety

    Thank was very helpful. Thanks

  • @Mastavalons
    @Mastavalons Před 5 lety

    Thank you for awesome video. Do you have plan to create video about memory profilers for windows - Visual Leak Detector or Deleaker?

  • @aaronleao
    @aaronleao Před 6 lety

    Very good video.

  • @ctzwu
    @ctzwu Před 9 lety

    thank you brian.

  • @MrTalJacob
    @MrTalJacob Před 3 lety

    Amazinggg THANK YOU!

  • @cwilsonpa
    @cwilsonpa Před 7 lety +2

    Are the sample code samples used in this tutorial available online?

  • @RobertFletcherOBE
    @RobertFletcherOBE Před 2 lety

    very useful thankyou! Its probably been said already but its pronouned 'val grinned' aparently its named after the gate to valhalla

  • @safouanebaroudi6190
    @safouanebaroudi6190 Před 9 lety

    Nice, good job.

  • @rakeshkumarthakur315
    @rakeshkumarthakur315 Před 4 lety

    Very nice sir thank you

  • @ajayguhan
    @ajayguhan Před 6 lety +1

    wow...! who taught you all these?....awesome tutorial..!

  • @mathon2462
    @mathon2462 Před 8 lety

    thanks dr faser

  • @Blattzumi
    @Blattzumi Před 4 lety

    Thanks for the tutorial! After valgrind completes the messages it says "segmentation fault" at the end. Does someone know what can be causing that?

  • @stefanolocci2325
    @stefanolocci2325 Před 8 lety

    Thanks!!

  • @itsNikitachan
    @itsNikitachan Před 6 lety

    thank you so much ;-;

  • @animeshkumar1201
    @animeshkumar1201 Před 3 lety

    Thanks sir

  • @braydonwiley8721
    @braydonwiley8721 Před 5 lety

    Thank you

  • @francisreycortes670
    @francisreycortes670 Před 7 lety

    What version of Valgrind is this?

  • @alantam3088
    @alantam3088 Před 3 lety

    There's some character which contains 0 0 7 F surrounded by a square at 15:33. What does that mean?

  • @vinaygupta8850
    @vinaygupta8850 Před 2 lety

    Hello, Can you tell me which tool can be used to Analyse Stack memory?

  • @smalinux
    @smalinux Před 3 lety

    thanks ))

  • @cavelinguam6444
    @cavelinguam6444 Před 4 lety

    Awesome

  • @user-hg5ss9vm6v
    @user-hg5ss9vm6v Před 3 lety

    7:04 Why not a sizeof(heights)? In your case it will be probably allocated malloc(3 * sizeof(8)), because pointer to int size is 8 bytes.

    • @sverkeren
      @sverkeren Před rokem

      heights is a pointer. sizeof a pointer has nothing to do with what it might point to.

  • @angel_machariel
    @angel_machariel Před 2 lety

    Why is sizeof(weights) correct instead of sizeof(* weights) ?
    In test 1 the pointer was de-referenced in malloc(), but not in test 2.

    • @sverkeren
      @sverkeren Před rokem +1

      Actually it is incorrect. It just happens to yield the same result as sizeof(long long) == sizeof(long long*).

  • @tivrfoa
    @tivrfoa Před 8 lety +7

    how to fix the last error?

    • @AfterDarknes
      @AfterDarknes Před 8 lety +13

      +tivrfoa you don't return strings/char-array in c. You make a char array before calling the method and passing its pointer as a parameter and this way you can change the string.

  • @ashishkokare9487
    @ashishkokare9487 Před 8 lety

    Hello DrBFraser could you please post a video on "How to install valgrind on Linux"
    I am finding difficulties with './configure' and 'make'.
    Just groping in the dark with no absolutely no clue on how to go about installing valgrind.

    • @finan2249
      @finan2249 Před 8 lety +2

      +ASHISH KOKARE I don't know if you still need help so please ignore this if you don't. Its actually pretty easy to build valgrind from source. I recommend you to create a new directory in you home directory. Mine is called Quellcode (thats german for source code). Download valgrind from valgrind.org. Unpack it in the directory you just created. There now should be a new directory called valgrind. Change into this directory. Then run ./configure. After that run make. Finally run sudo make install. That should be it. I hope this helps.

  • @rudhreshtrh4531
    @rudhreshtrh4531 Před 4 lety

    Hello Bro,
    How to find memory leakage of python Django application with valgrind tool

  • @himanshukumargupta9993

    This is for linux only??

  • @sghsghdk
    @sghsghdk Před 5 lety

    sizeof(weights) on line 20 should be sizeof(*weights)

  • @liorbm5779
    @liorbm5779 Před 6 lety

    how to do it in cpp?

  • @willer2k
    @willer2k Před 6 lety

    I'd give more thumbsup if I could.

  • @TheRealityKnight
    @TheRealityKnight Před 9 lety +1

    in line 20 it should be sizeof(*wieghts)

  • @EstebanQuijada
    @EstebanQuijada Před 8 lety +1

    now I see! I can see!!!

  • @lonisballington7636
    @lonisballington7636 Před 5 lety

    You sound like Khan from KhanAcademy

  • @therealguy12378
    @therealguy12378 Před 5 lety

    automatic scalling

  • @joserodellastudela7265

    Talk of barcelona

  • @dslayervamprunescape
    @dslayervamprunescape Před 4 lety

    He sounds like Khan Academy

  • @souffag2579
    @souffag2579 Před 3 lety

    what is the password?

  • @marcuschan4897
    @marcuschan4897 Před 2 lety

    dude sounds just like khan academy

  • @denisrabotay
    @denisrabotay Před rokem

    didn't helped me at all , I got "by ADDRESS ???"

  • @joserodellastudela7265

    I understand your source code. Better freebsd, openbsd, aix, debian. Umm beginner advanced C/C++, please talk of makefile why know little.
    This tutorial are for beginners.
    With 21 years write virus of bios, why are in age of turkey.
    Umm, take lottery with matematicals with C.
    Not are hacker I am programmer of video games and graphic design.
    Umm mostly libraries harder *.C are portable to windows.
    Mac os big sur are Unix shit but are Unix to beginner people.
    In free time write Unix BSD and system V.
    huhhuhu make ftp and compile with freebsd to write 50 gigabytes, with new portable leonovo with 600 megas are slow.
    Mostly freebsd download ports for freebsd.
    At home have freebsd 12.2 need upgrade and have debian, Mac os big sur.
    Will write aix, sco, solaris, aix, slackware, Ubuntu, openbsd, netbsd, dragonfly bsd.
    With pascal with much libraries and gimp make game how street fighter can make alone.
    But not are music, umm fpc(pascal are how basic).
    Make code of 100 or 200k in C/C++.
    But C/C++ need perl, awk
    Ummm to make game need matematicals.
    Don't work with windows

  • @joserodellastudela7265

    Like learn medicine, don't have much money in this moment to go university.
    Like are doctor, know much of all.
    Are very old with computers and network.
    You talk of source code to beginner, talk of artificial intelligence, for example bots of irc.

  • @joserodellastudela7265

    Have 22 or 23 portables, Dell, leonovo, hp, acer, much Macintosh for example Mac pro xeon and imac with chip m1, 6 or 7 Macintosh portables and imac.
    In free time make laboratory, huhuu configure bios of various portables and write much Unix, make ftp with Unix bsd are nightmare.
    To write frebsd 12.2 with 39 gigabytes, huhu to 600 megas need more 6 hours.
    Your tutorial of are to children of 13 years, are very easy.
    With C/C++ with various source codes can make 4 sprites with makefile.
    Make little game in C, how xbill are easy.
    Download pdf tutorial and html tutorials.
    46 years of Catalonia, first computer dragon 64k with Unix and spectrum 128k more later pc xt without hardisk.
    Your source code are easy, please talk of opengl, know someone librarys but know little SDL2, your source code are ridiculous.
    Repair computers how Intel or imac, are easy to me.
    I am asperger and tda, little schizophrenia.
    Pensionist and disabled 33%, ummm don't tittle, tecnic engineer in 3 months, almost engineer of network.
    Routers Cisco are good, switch will buy.
    My name is ivan and have wife.