On Mon, Jul 22, 2019 at 11:10:51AM +0300, Gal Pressman wrote: > Hi all, > > I'm seeing memory leaks when running tests with valgrind memcheck tool [1]. It > seems like it's caused due to verbs_device refcount never reaching zero. > > Last related commit is 8125fdeb69bb ("verbs: Avoid ibv_device memory leak"), > which seems like it should prevent this issue - but I'm not sure it covers all > cases. > > When calling ibv_get_device_list, try_driver will eventually get called and set > the device refcount to one. The refcount for each device will be increased when > iterating the devices list, and on each verbs_init_context call. > > In the free flow, the refcount is decreased on verbs_uninit_context and when > iterating the devices list - which brings the refcount back to one, as initially > set by try_driver (hence uninit_device isn't called). It is supposed to cache the device list in the library (device.:device_list) and there is no function to cleanup the cache to silence the valgrind warnings. Jason