About memory leak

==43459== Memcheck, a memory error detector
==43459== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==43459== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==43459== Command: ./Dlist
==43459==
==43459==
==43459== HEAP SUMMARY:
==43459== in use at exit: 18,024 bytes in 160 blocks
==43459== total heap usage: 181 allocs, 21 frees, 26,472 bytes allocated
==43459==
==43459== 72 bytes in 3 blocks are possibly lost in loss record 25 of 40
==43459== at 0x1000AAFF2: calloc (vg_replace_malloc.c:755)
==43459== by 0x1008447E2: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==43459== by 0x1008577DA: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==43459== by 0x100006C64: dyld::notifyBatchPartial(dyld_image_states, bool, char const* ()(dyld_image_states, unsigned int, dyld_image_info const), bool, bool) (in /usr/lib/dyld)
==43459== by 0x100006E39: dyld::registerObjCNotifiers(void ()(unsigned int, char const const*, mach_header const* const*), void ()(char const, mach_header const*), void ()(char const, mach_header const*)) (in /usr/lib/dyld)
==43459== by 0x10030F71D: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==43459== by 0x100844075: _objc_init (in /usr/lib/libobjc.A.dylib)
==43459== by 0x100299B34: _os_object_init (in /usr/lib/system/libdispatch.dylib)
==43459== by 0x100299B1B: libdispatch_init (in /usr/lib/system/libdispatch.dylib)
==43459== by 0x1001749C2: libSystem_initializer (in /usr/lib/libSystem.B.dylib)
==43459== by 0x100018A79: ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==43459== by 0x100018CA9: ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==43459==
==43459== LEAK SUMMARY:
==43459== definitely lost: 0 bytes in 0 blocks
==43459== indirectly lost: 0 bytes in 0 blocks
==43459== possibly lost: 72 bytes in 3 blocks
==43459== still reachable: 200 bytes in 6 blocks
==43459== suppressed: 17,752 bytes in 151 blocks
==43459== Reachable blocks (those to which a pointer was found) are not shown.
==43459== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==43459==
==43459== For counts of detected and suppressed errors, rerun with: -v
==43459== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 8 from 8)

The above is the error message. However, I am only compiling a single cpp with only main function which return 1:
"test.cpp":
int main()
{
return 1;
}

I cannot solve this out. Is this a problem with Valgrind on Macos?

2 comments

  • @ 2018-08-05 09:24:28

    My valgrind on Mac gives the same "72 bytes in 3 blocks" log. According to TA, as long as you do not see a function written by you appearing in the log, there should be no problem.

  • @ 2018-08-03 11:07:29

    Hi 李泽坤,

    I have encountered the same problem when it comes to using valgrind on Mac: always having memory leak in "possibly lost", "still reachable" and "suppressed". However, your memory usage in heap at exit does look weird. I would recommend you restarting your computer and let the system reflush the memory. If the problem persists, you should reach out to the professor or TA's according to your section see what they have to offer. Good luck!

    Sincerely,
    Haoran

    • @ 2018-08-03 12:52:13

      I tried restart just now but nothing changed. Maybe later I will try to reinstall Valgrind or do the memory check on other OS. Thank you!

  • 1