<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="margin: 0;"><br></div><div style="margin: 0;">Hi£¬</div><div style="margin: 0;"><br></div><div style="margin: 0;">When the busctl command is used to call the method corresponding to this function, the memory used by the process will increase after 65 ~ 70 times. If continue to call, the memory usage will continue to increase.</div><div style="margin: 0;">Refer to the method in SYSTEMd. (such as: ListUnits, GetDynamicUsers)</div><div style="margin: 0;"><br></div><div style="margin: 0;">Thanks,</div><div style="margin: 0;">Byron</div><p style="margin: 0;"><br></p><p style="margin: 0;"><br></p><div style="position:relative;zoom:1"></div><div id="divNeteaseMailCard"></div><p style="margin: 0;"><br></p><p>At 2022-01-22 22:25:35, "Dan Nicholson" <dbn@endlessos.org> wrote:</p><blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="auto"><div>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.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 22, 2022, 3:12 AM www <<a href="mailto:ouyangxuan10@163.com">ouyangxuan10@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="margin:0">+Add the implementation code of the method.</div><div style="margin:0"><br></div><div style="margin:0"><span style="font-size:12px"><i>static int method_load_info(sd_bus_message *message, void *userdata, sd_bus_err *error)</i></span></div><div style="margin:0"><span style="font-size:12px"><i>{</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    sd_bus_message *reply = NULL;</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    ......</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    r = sd_bus_message_read(message. "r", &xxx);</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    ......</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    r= <b>sd_bus_message_new_return</b>(message, &reply);     //</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    ......</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    r = sd_bus_message_open_container(reply, 'a', "(uuuu)");</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    ....</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    r = sd_bus_message_append(reply, "(uuuu)", xx, xx ,xx ,xx);</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    ......</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    r = sd_bus_message_close_container(reply);</i></span></div><div style="margin:0"><span style="font-size:12px"><i>    .......</i></span></div><div style="margin:0"><br></div><div style="margin:0"><span style="font-size:12px"><i>    return <b>sd_bus_send</b>(NULL, reply, NULL);</i></span></div><div style="margin:0"><span style="font-size:12px"><i>}</i></span></div><div style="margin:0"><br></div><div style="zoom:1"></div><div id="m_4216197791792531264divNeteaseMailCard"></div><div style="margin:0"><br></div><div style="margin:0">Thanks,</div><div style="margin:0">Byron</div><div style="margin:0"><br></div><p>At 2022-01-22 14:16:13, "www" <<a href="mailto:ouyangxuan10@163.com" target="_blank" rel="noreferrer">ouyangxuan10@163.com</a>> wrote:</p><blockquote id="m_4216197791792531264isReplyContent" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="line-height:1.7"><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px">Dear all,</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="margin:0px"><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px">When using <b>sd_bus_process() + sd_bus_wait() </b> 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. </div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="margin:0px">It should not be a problem with the DBUS method, because a single call does not increase memory, it needs to call the method <b>65 ~ 70 </b>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.</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="margin:0px">code implementation£º</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>int main()</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>{</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    ......</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    r = sd_bus_open_system(&bus);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    ...</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    r = sd_bus_add_object_vtable(bus, ......);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    ......</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    r= sd_bus_request_name(bus, "xxx.xx.xx.xxx");</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    ......</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    for( ; ; )</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    {</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>        r = sd_bus_process(bus, NULL);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>        .......</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>        r = sd_bus_wait(bus, -1);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>        ......</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    }</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    sd_bus_slot_unref(slot);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>    sd_bus_unref(bus);</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><span style="font-size:12px"><i>}</i></span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px">thanks,</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px">Byron</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;margin:0px"><br></div></div></div></div></blockquote></div><br><br><span title="neteasefooter"><p> </p></span></blockquote></div></div></div>
</blockquote></div><br><br><span title="neteasefooter"><p> </p></span>