qiboteam / qibo-core

Core qibo elements
https://qibo.science
1 stars 0 forks source link

Test for memory leaks #39

Open alecandido opened 2 weeks ago

alecandido commented 2 weeks ago

Since we're exposing a C API, and we'll have examples for its usage, we should not only test for the absence of errors while running, but even the possible memory leaks, using tools like Valgrind (possibly in the CI).

alecandido commented 2 weeks ago

Related to #38

scarrazza commented 2 weeks ago

We could use the compiler address sanitize option (-fsanitize=address). Usually, this is quite useful and simple to catch memory leaks when executing tests.

alecandido commented 2 weeks ago

Address sanitization is not the only one (I didn't know even that), and the other ones seem also pretty useful: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html e.g. -fsanitize=leak (particularly relevant for this issue).

However, here is a brief comparison with Valgrind: https://stackoverflow.com/a/47261999/8653979