Thanks Todd,<br><br>I opened the PingSender and PingReceiver files again and noticed the line that removes the relay. I must say the information I needed was there but didn&#39;t see it in the first place. Good thing you mentioned that the publishRemove has to take place from the relay originator.<br>
<br><br>Cheers<br>Dimitris<br><br><br><br><br><div><span class="gmail_quote">On 26/03/2008, <b class="gmail_sendername">Todd Wright</b> &lt;<a href="mailto:twright@bbn.com">twright@bbn.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Plugins must use publishRemove to cleanup publishAdd&#39;ed objects.<br> <br> The ping demo uses the following pattern:<br>&nbsp;&nbsp; 1. The &quot;PingSender&quot; publishAdd&#39;s a new relay<br>&nbsp;&nbsp; 2. The &quot;PingReceiver&quot; publishChange&#39;s the relay to send back a response<br>
&nbsp;&nbsp; 3. The &quot;PingSender&quot; publishRemove&#39;s its relay<br>&nbsp;&nbsp; 4. goto (1)<br> So, every ping iteration creates a new relay and removes it.&nbsp;&nbsp;We cleanup after<br> every iteration.&nbsp;&nbsp;Note that the relay must be publishRemove&#39;d on the agent<br>
 where it was publishAdd&#39;ed.<br> <br> Another common pattern is:<br>&nbsp;&nbsp; 1. The sender publishAdd&#39;s a new relay &quot;r1&quot;<br>&nbsp;&nbsp; 2. The receiver publishAdd&#39;s its response in a new relay &quot;r2&quot;<br>&nbsp;&nbsp; 3. The sender publishChange&#39;s relay &quot;r1&quot; in response to &quot;r2&quot;<br>
&nbsp;&nbsp; 4. The receiver publishChange&#39;s relay &quot;r2&quot; in response to &quot;r1&quot;<br>&nbsp;&nbsp; 5. goto (3)<br> In this pattern the two relays, &quot;r1&quot; and &quot;r2&quot;, acts as content &quot;channels&quot;.<br> There is no memory leak because we only publishAdd these two relays.<br>
 <br> There are advantages and disadvantages to both of these design patterns.<br> Either works fine in practice.<br> <br> Todd<br> <br><br> Dimitrios Traskas wrote:<br> &gt; Hi to all,<br> &gt;<br> &gt; I have a question in regards with Relays and objects in the Blackboard.<br>
 &gt; If an Agent A has an established communication with an Agent B and they<br> &gt; send to each other a number of messages what happens with messages that<br> &gt; have been read and processed? Are they &quot;garbage&quot; collected or is it the<br>
 &gt; responsibility of client code to get rid of them? I have thousand of<br> &gt; messages being sent between Agents and I am wondering what happens once<br> &gt; I go through a normal execute routine where I check the added messages<br>
 &gt; in a collection. Once I read the message what is the lifetime of that<br> &gt; message?<br> &gt;<br> &gt;<br> &gt; Cheers<br> &gt; Dimitris<br> &gt;<br> &gt;<br> <br>&gt; ------------------------------------------------------------------------<br>
 &gt;<br> &gt; _______________________________________________<br> &gt; Cougaar-developers mailing list<br> &gt; <a href="mailto:Cougaar-developers@cougaar.org">Cougaar-developers@cougaar.org</a><br> &gt; <a href="http://cougaar.org/mailman/listinfo/cougaar-developers">http://cougaar.org/mailman/listinfo/cougaar-developers</a><br>
 </blockquote></div><br>