I don't know how can I see memory leaks using CLion on MacOS Big Sur using CLion and I've tried these things:
Valgrind - which is not compatible with Big Sur
Leak Sanitizer from Clang - which apparently isn't compatible with MacOS according to a support guy from CLion
Inside CLion, I've written in CMakeLists.txt this command:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
then I've written in preferences menu -> sanitizers in Address sanitizer section:
detect_stack_use_after_return=1
Based on CLion support page, they said that Leak Sanitizer is included in Address sanitizer.
Normally you could use
libasan
during compilation (https://www.osc.edu/resources/getting_started/howto/howto_use_address_sanitizer) however on MacOS there are some extra steps :https://clang.llvm.org/docs/AddressSanitizer.html (search this page for 'MacOS' to get an overview) :
source : https://clang.llvm.org/docs/AddressSanitizer.html
Also see Mac OS: Leaks Sanitizer and https://developer.apple.com/documentation/xcode/diagnosing_memory_thread_and_crash_issues_early