Memory leak in C library


#1

Valgrind reports that allocated memory does not get removed:
==25320== 192 (176 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 200 of 252
==25320== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25320== by 0xB5101BB: lcb_create_libev_io_opts (plugin-libev.c:363)
==25320== by 0x7EC36BD: create_v1 (iofactory.c:232)
==25320== by 0x7EC3843: lcb_create_io_ops (iofactory.c:205)
Is there a counterpart for the lcb_create_io_ios() function that should be called to free() the allocated memory that I am not aware of?


#2

If you manually create an io ops structure you should call the destructor on the io ops when you’re done using it (it is part of the io-ops structure)


#3

Thanks for your answer. It turns out that there is a lcb_destroy_io_ops() function that I found in a .h file and that I missed (maybe overlooked) on the website.
Calling it solves the memory leak.