Skip to content

Memory Leaks with Clang

Siraj Razick edited this page Jul 11, 2015 · 1 revision

Detecting memory leaks with clang.

If you compile plexydesk with clang compiler then you can easily detect memory leaks following the following procedure. The build system will automatically detect this in the debug mode and add the required compiler flags to support produce required traces at runtime.

export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.6

ASAN_OPTIONS=detect_leaks=1 /usr/bin/plexydesk

Example

=================================================================
==7198==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1764000 byte(s) in 1 object(s) allocated from:
    #0 0x4c0792 in __interceptor_malloc (/home/siraj/project/plexydesk/code/plexydesk-1/clang/base/datastore/tests/datasync_runtime+0x4c0792)
    #1 0x7f6a0d9e611d in cherry::image_io::platform_image::load_from_file(std::string const&)::$_0::operator()() const /home/siraj/project/plexydesk/code/plexydesk-1/base/datastore/lib/qt5/qt_platform_image.cpp:43:43
    #2 0x7f6a0be79e2f  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xbae2f)
  • Coding Guidelines

Clone this wiki locally