[ofa-general] memory leak in librdmacm, libibverbs

Roland Dreier rdreier at cisco.com
Thu Jun 14 11:12:14 PDT 2007


 > I found a memory leak that is present in at least librdmacm and
 > libibverbs.  The libraries allow a user to get a device list, and later
 > free the device list.  In freeing the device list, the devices in the list
 > are not freed, causing a memory leak.  It would not be wise to free all
 > the devices in the list, either, because the user very likely wants to
 > continue using one of the devices that was returned in the list.  I think
 > the intent of the methods was for the list to live the life of the
 > program, but that might not be the way it gets used.

I don't see it.  Both rdma_get_devices() and ibv_get_device_list()
don't allocate anything beyond the list they return to the caller.
The device structures are just allocated once when the libraries
discover the devices.  And rdma_free_devices() and
ibv_free_device_list() both free exactly what the corresponding get
function allocated.

 > I included a short example program, run on a machine with devices
 > present it will consume all available memory.

I ran this program on a system where rdma_get_devices() reports 1
device found, and the memory used by the process does not increase
after startup, even after running for a few minutes.

 - R.



More information about the general mailing list