private connection seems always cause a memory leak
run this demo:
#include <stdio.h>
#include <unistd.h>
#include <dbus/dbus.h>
void test()
{
DBusConnection *dbus_conn = dbus_bus_get_private(DBUS_BUS_SESSION, NULL);
dbus_connection_close(dbus_conn);
dbus_connection_unref(dbus_conn);
}
int main()
{
int nIndex = 0;
while(TRUE)
{
printf("Test %d times\n", ++nIndex);
test();
usleep(100);
}
return 0;
}
see the top:
top - 16:27:40 up 2:04, 1 user, load average: 1.72, 3.41, 3.39
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.5 us, 0.0 sy, 0.0 ni, 93.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3856.0 total, 153.3 free, 2783.6 used, 919.0 buff/cache
MiB Swap: 8192.0 total, 5774.2 free, 2417.8 used. 449.3 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4421 planc 20 0 409464 257764 2008 S 0.0 6.5 9:50.96 dbus-daemon
RES
of dbus-daemon
will increase continuously, then exit the demo, the RES
will not reduce.