I am doing some linux programming and I encountered a situation where a library function from the blkid library leaks some memory... There is not too much documentation about it (https://www.kernel.org/pub/linux/utils/util-linux/v2.21/libblkid-docs/libblkid-Cache.html) so I turn to the community to find some cure to this problem.
The function is blkid_get_cache
and valgrind reports:
==29769== 4,129 (72 direct, 4,057 indirect) bytes in 1 blocks are definitely lost in loss record 68 of 69
==29769== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29769== by 0x67360BB: blkid_get_cache (in /lib/x86_64-linux-gnu/libblkid.so.1.1.0)
==29769== by 0x652DBAC: gather_disk_stat() (disk_status.cpp:96)
==29769== by 0x652DD5A: execute (disk_status.cpp:124)
==29769== by 0x42599B: PluginHelper::executeClientPlugin(plugin_descriptor*) (plugin_helper.cpp:333)
==29769== by 0x432BB5: main (main.cpp:48)
Now, this piece of code will be used in a daemon process which is supposed to run 24/7 so I would like to avoid the uncontrollable growth of memory.
Did anyone work with libblkid til now? How to fix this memory issue? (At an extreme case I could just free()
it ... but would it affect system stability?)