PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: Freeing at Exit Problem
Date: Thursday, 27 Feb 2020, 20:47:29


    > A ULA asked me to email you with my issue.
    >
    > I am failing to pass test case 12 on the public tests because I do not
    > free 16,958 bytes of code before exit.
    >
    > After looking through my code for 15 minutes, the ULA said this would be
    > a difficult issue to solve with gdb or valgrind.  He suggested I ask for
    > help or an extension.
    >
    > What can I do to make sure I am passing this case?

As stated in /c/cs223/Hwk3/Valgrind (also available as
https://zoo.cs.yale.edu/classes/cs223/current/Valgrind
and part of the reading for this assignment), valgrind
supports the following option:

  --leak-check= [default: summary]
    When enabled, search for memory leaks when the client program finishes.  If
    set to summary, it says how many leaks occurred.  If set to full or yes, it
    also gives details of each individual leak.

For example, running

  % echo a | valgrind --leak-check=full ./strwrs -Nn a bb b cc

gives

  ==491== 3 bytes in 1 blocks are definitely lost in loss record 1 of 1
  ==491==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
  ==491==    by 0x401761: lower (strwrs.c:241)
  ==491==    by 0x4016B6: upper (strwrs.c:196)
  ==491==    by 0x40145B: main (strwrs.c:102)

which should give you enough information to track down
where the last pointer to this block was lost.

--stan-
PREV INDEX NEXT