Re: [systemd-devel] sd_bus_process() + sd_bus_wait() is it not suitable for application?

2022-01-22 Thread Dan Nicholson
Aren't your leaking reply there? You don't seem to be unreffing it and it's
not being returned to someone else to do it either.

On Sat, Jan 22, 2022, 3:12 AM www  wrote:

> +Add the implementation code of the method.
>
> *static int method_load_info(sd_bus_message *message, void *userdata,
> sd_bus_err *error)*
> *{*
> *sd_bus_message *reply = NULL;*
> *..*
> *r = sd_bus_message_read(message. "r", );*
> *..*
> *r= sd_bus_message_new_return(message, ); //*
> *..*
> *r = sd_bus_message_open_container(reply, 'a', "()");*
> **
> *r = sd_bus_message_append(reply, "()", xx, xx ,xx ,xx);*
> *..*
> *r = sd_bus_message_close_container(reply);*
> *...*
>
> *return sd_bus_send(NULL, reply, NULL);*
> *}*
>
>
> Thanks,
> Byron
>
> At 2022-01-22 14:16:13, "www"  wrote:
>
> Dear all,
>
> When using *sd_bus_process() + sd_bus_wait() * to implement the
> application(Service), call the methods function on the service can obtain
> the correct information.  Run a certain number of times will lead to
> insufficient memory and memleak does occur.
>
> It should not be a problem with the DBUS method, because a single call
> does not increase memory, it needs to call the method *65 ~ 70 *times,
> and you will see the memory increase. After stopping the call, the memory
> will not decrease. It seems that it has nothing to do with the time
> interval when the method is called.
>
> code implementation:
> *int main()*
> *{*
> *..*
> *r = sd_bus_open_system();*
> *...*
> *r = sd_bus_add_object_vtable(bus, ..);*
> *..*
> *r= sd_bus_request_name(bus, "xxx.xx.xx.xxx");*
> *..*
>
> *for( ; ; )*
> *{*
> *r = sd_bus_process(bus, NULL);*
> *...*
> *r = sd_bus_wait(bus, -1);*
> *..*
> *}*
> *sd_bus_slot_unref(slot);*
> *sd_bus_unref(bus);*
> *}*
>
> thanks,
> Byron
>
>
>
>
>
>


Re: [systemd-devel] sd_bus_process() + sd_bus_wait() is it not suitable for application?

2022-01-22 Thread Cristian Rodríguez
What do you mean with memory increase ?
sd_bus is unlikely to have any severe memory leak under normal
conditions (if there is any, they are usually found in error paths) so
you are either mis-using the api or misunderstanding memory
management. if there is any memory leak either in your code or in
sd_bus it will be found building both your code and systemd with leak
sanitizer.

On Sat, Jan 22, 2022 at 3:16 AM www  wrote:
>
> Dear all,
>
> When using sd_bus_process() + sd_bus_wait()  to implement the 
> application(Service), call the methods function on the service can obtain the 
> correct information.  Run a certain number of times will lead to insufficient 
> memory and memleak does occur.
>
> It should not be a problem with the DBUS method, because a single call does 
> not increase memory, it needs to call the method 65 ~ 70 times, and you will 
> see the memory increase. After stopping the call, the memory will not 
> decrease. It seems that it has nothing to do with the time interval when the 
> method is called.
>
> code implementation:
> int main()
> {
> ..
> r = sd_bus_open_system();
> ...
> r = sd_bus_add_object_vtable(bus, ..);
> ..
> r= sd_bus_request_name(bus, "xxx.xx.xx.xxx");
> ..
>
> for( ; ; )
> {
> r = sd_bus_process(bus, NULL);
> ...
> r = sd_bus_wait(bus, -1);
> ..
> }
> sd_bus_slot_unref(slot);
> sd_bus_unref(bus);
> }
>
> thanks,
> Byron
>
>
>
>
>
>
>
>
>


Re: [systemd-devel] sd_bus_process() + sd_bus_wait() is it not suitable for application?

2022-01-22 Thread www
+Add the implementation code of the method.


static int method_load_info(sd_bus_message *message, void *userdata, sd_bus_err 
*error)
{
sd_bus_message *reply = NULL;
..
r = sd_bus_message_read(message. "r", );
..
r= sd_bus_message_new_return(message, ); //
..
r = sd_bus_message_open_container(reply, 'a', "()");

r = sd_bus_message_append(reply, "()", xx, xx ,xx ,xx);
..
r = sd_bus_message_close_container(reply);
...


return sd_bus_send(NULL, reply, NULL);
}




Thanks,
Byron



At 2022-01-22 14:16:13, "www"  wrote:

Dear all,


When using sd_bus_process() + sd_bus_wait()  to implement the 
application(Service), call the methods function on the service can obtain the 
correct information.  Run a certain number of times will lead to insufficient 
memory and memleak does occur. 


It should not be a problem with the DBUS method, because a single call does not 
increase memory, it needs to call the method 65 ~ 70 times, and you will see 
the memory increase. After stopping the call, the memory will not decrease. It 
seems that it has nothing to do with the time interval when the method is 
called.


code implementation:
int main()
{
..
r = sd_bus_open_system();
...
r = sd_bus_add_object_vtable(bus, ..);
..
r= sd_bus_request_name(bus, "xxx.xx.xx.xxx");
..


for( ; ; )
{
r = sd_bus_process(bus, NULL);
...
r = sd_bus_wait(bus, -1);
..
}
sd_bus_slot_unref(slot);
sd_bus_unref(bus);
}


thanks,
Byron