<div dir="ltr">Hi All, <div><br></div><div><br></div><div>I have implemented a dbus application using dbus-1 API's on the linux platform. </div><div><br></div><div>Facing issues ,when we run continuously in a loop. dbsu Tx (public)and  dbus Rx (subscribe)  runs out of cache memory  and  both Tx and Rx getting terminated  attached source and header files,   </div><div> </div><div><img src="cid:ii_llaqjvtf1" alt="image.png" width="562" height="315"><br></div><div><br></div><div><br></div><div><br></div><div><b>1. Publish functions : Tx dbus application </b></div><div><br></div><div style="padding:0px 0px 0px 2px"><div style="color:rgb(0,0,0);font-family:monospace;font-size:10pt;white-space:pre"><p style="margin:0px"><span style="color:rgb(63,127,95)">/*</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * method:     method name</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payload</span><span style="color:rgb(63,127,95)">:    data that needs to be sent/published.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payloadlen</span><span style="color:rgb(63,127,95)">: length of </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payload</span><span style="color:rgb(63,127,95)"> in bytes.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * return:     0 on success, -1 on failure.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> */</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)">/*</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * method:     method name</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payload</span><span style="color:rgb(63,127,95)">:    data that needs to be sent/published.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payloadlen</span><span style="color:rgb(63,127,95)">: length of </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">payload</span><span style="color:rgb(63,127,95)"> in bytes.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * return:     0 on success, -1 on failure.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> */</span></p><p style="margin:0px"><span style="color:rgb(127,0,85);font-weight:bold">int</span> <span style="font-weight:bold">dbus_client_publish</span> (<span style="color:rgb(127,0,85);font-weight:bold">char</span> *method, <span style="color:rgb(127,0,85);font-weight:bold">void</span> *payload, <span style="color:rgb(127,0,85);font-weight:bold">int</span> payloadlen)</p><p style="margin:0px">{</p><p style="margin:0px">   <span style="color:rgb(0,80,50)">DBusMessage</span> *msg;</p><p style="margin:0px">   <span style="color:rgb(0,80,50)">DBusMessageIter</span> args;</p><p style="margin:0px">   <span style="color:rgb(0,80,50)">DBusMessageIter</span> subiter;</p><p style="margin:0px">   <span style="color:rgb(0,80,50)">DBusError</span> err;</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> returnValue = -1;</p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> SignalRetryCount = 0;</p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> SendRetryCount = 0;</p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> maxRetries = 3;</p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> successConnect = 0;</p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">int</span> successSend = 0;</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">char</span> *pload = (<span style="color:rgb(127,0,85);font-weight:bold">char</span>*) payload;</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">if</span>(pload != NULL)</p><p style="margin:0px">   {</p><p style="margin:0px">      <span style="color:rgb(63,127,95)">// initialize the errors</span></p><p style="margin:0px">      <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_init</span> (&err);</p><p style="margin:0px"><br></p><p style="margin:0px">      <span style="color:rgb(127,0,85);font-weight:bold">while</span> (SignalRetryCount < maxRetries && !successConnect)</p><p style="margin:0px">      {</p><p style="margin:0px"><br></p><p style="margin:0px">         <span style="color:rgb(63,127,95)">// create a new method call and check for errors</span></p><p style="margin:0px">         msg = <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_new_signal</span> (DBUS_OBJECT_NAME, <span style="color:rgb(63,127,95)">// object name of the signal</span></p><p style="margin:0px">                                        DBUS_INTERFACE_NAME, <span style="color:rgb(63,127,95)">// interface name of the signal</span></p><p style="margin:0px">                                        method); <span style="color:rgb(63,127,95)">// name of the signal</span></p><p style="margin:0px"><br></p><p style="margin:0px">         <span style="color:rgb(127,0,85);font-weight:bold">if</span>(NULL == msg)</p><p style="margin:0px">         {</p><p style="margin:0px">            <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_free</span> (&err);</p><p style="margin:0px"><br></p><p style="margin:0px">            SignalRetryCount++;</p><p style="margin:0px">         }</p><p style="margin:0px">         <span style="color:rgb(127,0,85);font-weight:bold">else</span></p><p style="margin:0px">         {</p><p style="margin:0px">            <span style="color:rgb(63,127,95)">// append arguments</span></p><p style="margin:0px">            <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_iter_init_append</span> (msg, &args);</p><p style="margin:0px"><br></p><p style="margin:0px">            <span style="color:rgb(63,127,95)">// For appending </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">args</span><span style="color:rgb(63,127,95)">, doc says to use the following 3 for container types.</span></p><p style="margin:0px">            <span style="color:rgb(63,127,95)">// We can view the </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">cmd</span><span style="color:rgb(63,127,95)"> buffer as a char buffer and send</span></p><p style="margin:0px">            <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_iter_open_container</span> (&args, DBUS_TYPE_ARRAY, <span style="color:rgb(42,0,255)">"y"</span>, &subiter);</p><p style="margin:0px">            <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_iter_append_fixed_array</span> (&subiter, DBUS_TYPE_BYTE, &pload, payloadlen);</p><p style="margin:0px"><br></p><p style="margin:0px">            <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_iter_</span><span style="font-size:10pt">2. Rx application with multiple functions </span></p><p style="margin:0px"><span style="color:rgb(100,40,128);font-weight:bold">close_container</span> (&args, &subiter);</p><p style="margin:0px"><br></p><p style="margin:0px">            <span style="color:rgb(63,127,95)">// We probably don't need a reply</span></p><p style="margin:0px">             flogv(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d dbus_connection_send called"</span>,__func__,__LINE__);</p><p style="margin:0px"><br></p><p style="margin:0px">            <span style="color:rgb(127,0,85);font-weight:bold">while</span> (SendRetryCount < maxRetries && !successSend)</p><p style="margin:0px">            {</p><p style="margin:0px">               <span style="color:rgb(127,0,85);font-weight:bold">if</span>(!<span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_send</span> (txconn, msg, NULL))</p><p style="margin:0px">               {</p><p style="margin:0px">                    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Out Of Memory!"</span>,__func__,__LINE__);</p><p style="margin:0px">                  SendRetryCount++;</p><p style="margin:0px">               }</p><p style="margin:0px">               <span style="color:rgb(127,0,85);font-weight:bold">else</span></p><p style="margin:0px">               {</p><p style="margin:0px">                  successConnect = 1;</p><p style="margin:0px">                  successSend = 1;</p><p style="margin:0px">                  returnValue = 0;</p><p style="margin:0px">                  <span style="color:rgb(127,0,85);font-weight:bold">break</span>;</p><p style="margin:0px">               }</p><p style="margin:0px">            }</p><p style="margin:0px">         }</p><p style="margin:0px">      }</p><p style="margin:0px"><br></p><p style="margin:0px">      <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_flush</span> (txconn);</p><p style="margin:0px"><br></p><p style="margin:0px">      <span style="color:rgb(63,127,95)">// free message</span></p><p style="margin:0px">      <span style="color:rgb(100,40,128);font-weight:bold">dbus_message_unref</span> (msg);</p><p style="margin:0px">      <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_free</span> (&err);</p><p style="margin:0px"><br></p><p style="margin:0px">      <span style="color:rgb(63,127,95)">//</span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">flogd</span><span style="color:rgb(63,127,95)">("dbustest.log","%s:%d Exit (no errors)",__</span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">func</span><span style="color:rgb(63,127,95)">__,__LINE__);</span></p><p style="margin:0px">   }</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(63,127,95)">// print ( dbus_client_publish, returnValue)</span></p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(127,0,85);font-weight:bold">return</span> returnValue;</p><p style="margin:0px">}</p><p style="margin:0px"></p></div></div><div> </div><div><br></div><div> </div><div><br></div><div><b>2. Rx application - with multiple functions </b></div><div><br></div><div><br></div><div><div style="padding:0px 0px 0px 2px"><div style="color:rgb(0,0,0);font-family:monospace;font-size:10pt;white-space:pre"><p style="margin:0px"><span style="color:rgb(63,127,95)">/* This API subscribes for a particular </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">busname</span><span style="color:rgb(63,127,95)">/interface/method. The callback would</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * be called once the subscribed information is available.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> *Note: subscribe = listen => server bus name (e.g.,).</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> *</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * method:    method name you want to listen to.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">cb</span><span style="color:rgb(63,127,95)">:        callback to be called once the subscribed information is available.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> * return:    0 on success, -1 on failure.</span></p><p style="margin:0px"><span style="color:rgb(63,127,95)"> */</span></p><p style="margin:0px"><span style="color:rgb(127,0,85);font-weight:bold">int</span> <span style="background-color:rgb(212,212,212);font-weight:bold">dbus_client_subscribe</span> (<span style="color:rgb(127,0,85);font-weight:bold">int</span> num_pairs, ...)</p><p style="margin:0px">{</p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Entry"</span>,__func__,__LINE__);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">int</span> i;</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">va_list</span> vargs;</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">rx_thread_args_t</span> *args;</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (num_pairs > 32)</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">return</span> -1;</p><p style="margin:0px"><br></p><p style="margin:0px">    args = (<span style="color:rgb(0,80,50)">rx_thread_args_t</span> *) <span style="color:rgb(100,40,128);font-weight:bold">malloc</span> (<span style="color:rgb(127,0,85);font-weight:bold">sizeof</span>(<span style="color:rgb(0,80,50)">rx_thread_args_t</span>));</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (args == NULL)</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">return</span> -1;</p><p style="margin:0px"><br></p><p style="margin:0px">    args-><span style="color:rgb(0,0,192)">num_pairs</span> = num_pairs;</p><p style="margin:0px">    va_start(vargs, num_pairs);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">for</span> (i = 0; i < num_pairs; i++)</p><p style="margin:0px">    {</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">char</span> *m = va_arg(vargs, <span style="color:rgb(127,0,85);font-weight:bold">char</span> *);</p><p style="margin:0px">        <span style="color:rgb(100,40,128);font-weight:bold">sprintf</span> (args-><span style="color:rgb(0,0,192)">mthod_cb</span>[i].<span style="color:rgb(0,0,192)">method</span>, <span style="color:rgb(42,0,255)">"%s"</span>, m);</p><p style="margin:0px">        args-><span style="color:rgb(0,0,192)">mthod_cb</span>[i].<span style="color:rgb(0,0,192)">cb</span> = va_arg(vargs, <span style="color:rgb(127,0,85);font-weight:bold">void</span> *);</p><p style="margin:0px">    }</p><p style="margin:0px">    va_end(vargs);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (<span style="color:rgb(100,40,128);font-weight:bold">pthread_create</span> (&dbus_client_rx_thread, NULL, dbus_client_receive_thread, (<span style="color:rgb(127,0,85);font-weight:bold">void</span> *)args) != 0)</p><p style="margin:0px">    {</p><p style="margin:0px">        floge(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Client Error: </span><span style="color:rgb(42,0,255);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">Rx</span><span style="color:rgb(42,0,255)"> Thread creation failed; </span><span style="color:rgb(42,0,255);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">errno</span><span style="color:rgb(42,0,255)"> = %d (%s)"</span>,__func__,__LINE__, errno, <span style="color:rgb(100,40,128);font-weight:bold">strerror</span>(errno));</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">return</span> -1;</p><p style="margin:0px">    }</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(63,127,95)">// free(</span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">args</span><span style="color:rgb(63,127,95)">);</span></p><p style="margin:0px"><br></p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d exit"</span>,__func__,__LINE__);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">return</span> 0;</p><p style="margin:0px">}</p><p style="margin:0px"><br></p><div style="padding:0px 0px 0px 2px"><div style="font-size:10pt"><p style="margin:0px"><span style="color:rgb(63,127,95)">* Receive thread */</span></p><p style="margin:0px"><span style="color:rgb(127,0,85);font-weight:bold">static</span> <span style="color:rgb(127,0,85);font-weight:bold">void</span> *<span style="background-color:rgb(212,212,212);font-weight:bold">dbus_client_receive_thread</span> (<span style="color:rgb(127,0,85);font-weight:bold">void</span> *arg)</p><p style="margin:0px">{</p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Entry"</span>,__func__,__LINE__);</p><p style="margin:0px"><br></p><p style="margin:0px">   <span style="color:rgb(0,80,50)">rx_thread_args_t</span> *args = (<span style="color:rgb(0,80,50)">rx_thread_args_t</span> *) arg;</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(0,80,50)">DBusError</span> err;</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">int</span> rc;</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">dbus_ctx_t</span> *lctx;</p><p style="margin:0px"><br></p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Entry"</span>,__func__,__LINE__);</p><p style="margin:0px">    ev_base = <span style="color:rgb(100,40,128);font-weight:bold">event_base_new</span> ();</p><p style="margin:0px"><br></p><p style="margin:0px">     <span style="color:rgb(63,127,95)">// </span><span style="color:rgb(63,127,95);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">initialise</span><span style="color:rgb(63,127,95)"> the error</span></p><p style="margin:0px"> <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_init</span>(&err);</p><p style="margin:0px"><br></p><p style="margin:0px">  lctx = dbus_init(ev_base);</p><p style="margin:0px">      lctx-><span style="color:rgb(0,0,192)">args</span> = args;</p><p style="margin:0px">     rc = <span style="color:rgb(100,40,128);font-weight:bold">event_base_dispatch</span>(ev_base);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (rc == -1)</p><p style="margin:0px">   {</p><p style="margin:0px">               flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d %s: Exit (</span><span style="color:rgb(42,0,255);text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,128,64)">rc</span><span style="color:rgb(42,0,255)"> = %d)\n"</span>,__func__,__LINE__, rc);</p><p style="margin:0px">       }</p><p style="margin:0px">       <span style="color:rgb(127,0,85);font-weight:bold">else</span></p><p style="margin:0px">    {</p><p style="margin:0px">               <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_free</span>(&err);</p><p style="margin:0px">    }</p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(127,0,85);font-weight:bold">return</span> 0;</p><p style="margin:0px">}</p><p style="margin:0px"></p></div></div></div></div></div><div><br></div><div><div style="padding:0px 0px 0px 2px"><div style="color:rgb(0,0,0);font-family:monospace;font-size:10pt;white-space:pre"><p style="margin:0px"><span style="color:rgb(127,0,85);font-weight:bold">static</span> <span style="color:rgb(0,80,50)">dbus_ctx_t</span> *<span style="font-weight:bold">dbus_init</span>(<span style="color:rgb(127,0,85);font-weight:bold">struct</span> <span style="color:rgb(0,80,50)">event_base</span> *eb)</p><p style="margin:0px">{</p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Entry"</span>,__func__,__LINE__);</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">DBusConnection</span> *conn = rxconn;</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">DBusError</span> err;</p><p style="margin:0px">    <span style="color:rgb(0,80,50)">dbus_ctx_t</span> *<span style="background-color:rgb(240,216,168)">ctx</span> = &gctx;</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">char</span> match_buffer[255];</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">int</span> len1;</p><p style="margin:0px"><br></p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Entry"</span>,__func__,__LINE__);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_set_exit_on_disconnect</span>(conn, FALSE);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="background-color:rgb(212,212,212)">ctx</span>-><span style="color:rgb(0,0,192)">conn</span> = conn;</p><p style="margin:0px">    <span style="background-color:rgb(212,212,212)">ctx</span>-><span style="color:rgb(0,0,192)">evbase</span> = eb;</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">event_assign</span>(&<span style="background-color:rgb(212,212,212)">ctx</span>-><span style="color:rgb(0,0,192)">dispatch_ev</span>, eb, -1, EV_TIMEOUT, dispatch, <span style="background-color:rgb(212,212,212)">ctx</span>);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (!<span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_set_watch_functions</span>(conn, add_watch, remove_watch,</p><p style="margin:0px">                                             toggle_watch, <span style="background-color:rgb(212,212,212)">ctx</span>, NULL)) {</p><p style="margin:0px">       flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%ddbus_connection_set_watch_functions() failed"</span>,__func__,__LINE__);</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">goto</span> out;</p><p style="margin:0px">    }</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_set_dispatch_status_function</span>(conn, handle_dispatch_status,</p><p style="margin:0px">                                                 <span style="background-color:rgb(212,212,212)">ctx</span>, NULL);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(63,127,95)">// add a rule for which messages we want to see</span></p><p style="margin:0px">    len1 = <span style="color:rgb(100,40,128);font-weight:bold">strlen</span>(<span style="color:rgb(42,0,255)">"type='signal',interface='"</span>);</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">sprintf</span> (match_buffer, <span style="color:rgb(42,0,255)">"%s"</span>, <span style="color:rgb(42,0,255)">"type='signal',interface='"</span>);</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">sprintf</span> (match_buffer+len1, <span style="color:rgb(42,0,255)">"%s"</span>, DBUS_INTERFACE_NAME);</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">sprintf</span>(match_buffer+len1+<span style="color:rgb(100,40,128);font-weight:bold">strlen</span>(DBUS_INTERFACE_NAME), <span style="color:rgb(42,0,255)">"%s"</span>, <span style="color:rgb(42,0,255)">"'"</span>);</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_init</span>(&err);</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_bus_add_match</span>(conn, match_buffer, &err); <span style="color:rgb(63,127,95)">// see signals from the given interface</span></p><p style="margin:0px">   <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_flush</span>(conn);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (<span style="color:rgb(100,40,128);font-weight:bold">dbus_error_is_set</span>(&err)) {</p><p style="margin:0px">       flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Match Error (%s)"</span>,__func__,__LINE__, err.<span style="color:rgb(0,0,192)">message</span>);</p><p style="margin:0px">        <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_free</span>(&err);</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">goto</span> out;</p><p style="margin:0px">    }</p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_error_free</span>(&err);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (<span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_register_object_path</span>(conn, DBUS_OBJECT_NAME, &dbus_vtable,</p><p style="margin:0px">                                             <span style="background-color:rgb(212,212,212)">ctx</span>) != TRUE) {</p><p style="margin:0px">       flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d failed to register object path\n"</span>,__func__,__LINE__);</p><p style="margin:0px">        <span style="color:rgb(127,0,85);font-weight:bold">goto</span> out;</p><p style="margin:0px">    }</p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_unref</span>(conn);</p><p style="margin:0px"><br></p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">return</span> <span style="background-color:rgb(212,212,212)">ctx</span>;</p><p style="margin:0px"><br></p><p style="margin:0px">out:</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">if</span> (conn) {</p><p style="margin:0px">        <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_close</span>(conn);</p><p style="margin:0px">        <span style="color:rgb(100,40,128);font-weight:bold">dbus_connection_unref</span>(conn);</p><p style="margin:0px">    }</p><p style="margin:0px">    flogd(<span style="color:rgb(42,0,255)">"dbustest.log"</span>,<span style="color:rgb(42,0,255)">"%s:%d Exit"</span>,__func__,__LINE__);</p><p style="margin:0px">    <span style="color:rgb(127,0,85);font-weight:bold">return</span> NULL;</p><p style="margin:0px">}</p><p style="margin:0px"></p></div></div></div><div><br></div><div><br></div><div>Please suggest to me, Is any dbus API  to avoid the above application consuming lots of system cache memory ?</div><div><br></div><div>Regards,</div><div>Deepak Jewargi</div><div><br></div><div>-------------------------------------------------------------------------------------------------------------------------------------------</div><div><br></div></div>