Closed odiszapc closed 5 years ago
Hi, thank you for the testing.
I checked the testing code and no memory leak was found!
Maybe you write your own main.cpp and call exit() from the main ? which may cause the thread local variable not freed.
test.cpp
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
TEST_CASE("Test"){
promise::Defer promise = promise::newPromise();
}
compiled by
g++ -I promise -I Catch2/single_include test.cpp
result after run
valgrind --leak-check=full --show-leak-kinds=all ./a.out
==27275== Memcheck, a memory error detector
==27275== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==27275== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==27275== Command: ./a.out
==27275==
===============================================================================
test cases: 1 | 1 passed
assertions: - none -
==27275==
==27275== HEAP SUMMARY:
==27275== in use at exit: 0 bytes in 0 blocks
==27275== total heap usage: 1,784 allocs, 1,784 frees, 318,385 bytes allocated
==27275==
==27275== All heap blocks were freed -- no leaks are possible
==27275==
==27275== For counts of detected and suppressed errors, rerun with: -v
==27275== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Thanks for the feedback! My bad, I tried older relaese (not from master) where no deallocation on thread exit was implemented.
Thank you!
First of all, thank you for the perfect lib! Promise implementation is good and clean. Looking into the lib deeply.
After running this simple line code using Catch framework with
valgrind --leak-check=full --show-leak-kinds=all
:two "still reachable" warnings was thrown:
I guess both point to custom memory allocator:
The first one:
The second:
In both cases I see memory allocation which are once allocated (fix me if I'm wrong) will never be freed.
I'm not sure this is 100% memory leak, but in more complex production examples instead of "still reachable" I see "possibly lost" or even "definitely lost" warnings pointing to the same lines of code.
Could you please clarify this issue, I saw
static thread_local
memory pooling logic inside, so maybe we could implement some function whose responsibility would be to clear all the pools manually to make valgrind happy? Like this:Thank you.