<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Hi Duncan,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span><span style="font-family: monospace; font-size: 13px;">The original object reference is kept for as long as the application</span><br clear="none" style="font-family: monospace; font-size: 13px;"><span style="font-family: monospace; font-size: 13px;">code holds on to the object reference. The forwarded reference can fail</span><br clear="none" style="font-family: monospace; font-size: 13px;"><span style="font-family: monospace; font-size: 13px;">at any time, and if it does it reverts back to the original location.</span></span></div><div style="color: rgb(0, 0, 0);
 font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span><span style="font-family: monospace; font-size: 13px;">&gt; CORBA::WStringValue* l_sayHelloPtr = TaskWork.m_HelloObj-&gt;sayHello();</span><br clear="none" style="font-family: monospace; font-size: 13px;"><br clear="none" style="font-family: monospace; font-size: 13px;"><span style="font-family: monospace; font-size: 13px;">You are responsible for releasing the WStringValue pointer. It's a leak</span><br clear="none" style="font-family: monospace; font-size: 13px;"><span style="font-family: monospace; font-size: 13px;">in your code, not in omniORB, if you don't release it.</span><br clear="none" style="font-family: monospace; font-size: 13px;"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande',
 sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span style="background-color: transparent;">&gt;&gt; Maybe I need to give some more info about this, the IDL I used has the following:</span><br></div><div style="background-color: transparent;"><font face="monospace" size="2">module helloInterface {</font></div><div style="background-color: transparent;"><font face="monospace" size="2">&nbsp; &nbsp; interface HelloInt {</font></div><div style="background-color: transparent;"><font face="monospace" size="2">&nbsp; &nbsp; &nbsp; &nbsp; ::CORBA::WStringValue sayHello( );</font><span style="font-family: monospace; font-size: 13px; background-color: transparent;">&nbsp; &nbsp;&nbsp;</span></div><div style="background-color:
 transparent;"><font face="monospace" size="2">&nbsp; &nbsp; };</font></div><div style="background-color: transparent;"><font face="monospace" size="2">#pragma ID HelloInt "RMI:helloInterface.HelloInt:0000000000000000"</font></div><div style="background-color: transparent;"><font face="monospace" size="2">};</font></div><div>When I compiled the IDL using omniidl, it produced the C++ header and implementation files containing this:</div><div><div>&nbsp; &nbsp; CORBA::WStringValue* sayHello();</div><div>At first I was not expecting (DID NOT NOTICE) sayHello() would return a pointer since the method signature in the IDL file does not (or maybe this is my fault for not reading the CORBA specs)...I just came to realize when I eventually noticed that the return value is a pointer...that sayHello() method was probably doing some internal allocations. &nbsp;I am just wondering though, if you take a look at the declaration, I declared a _var object
 (m_HelloObj)..but the sayHello method (which is a member of the object m_HelloObj) isn't doing an automatic cleanup. &nbsp;In short, the _var object itself is automatically cleaning up it's allocations, but not allocations made by its member methods.</div><div>For a first time orb user like me, these two would look the same:</div><div>Version 1:</div><div><div>CORBA::WStringValue_var l_sayHello = TaskWork.m_HelloObj-&gt;sayHello();</div><div><span style="font-size: 12pt;">*lClientRequest = l_sayHello-&gt;_boxed_out();</span><br></div><div>Version 2:</div><div>*lClientRequest = TaskWork.m_HelloObj-&gt;sayHello()-&gt;_boxed_out();<br></div><div><br></div><div>...but they don't perform the same, Version 1 doesn't cause leaks, Version 2 does. &nbsp;(Keep in mind m_HelloObj is declared as _var, so I was expecting that anything the object allocates, even those allocated through it's member methods, would automatically be deallocated upon
 destruction).</div><div><br></div></div><div><span style="font-family: monospace; font-size: 13px;">Or, probably better, use a _var that automatically calls _remove_ref</span><br clear="none" style="font-family: monospace; font-size: 13px;"><span style="font-family: monospace; font-size: 13px;">when it goes out of scope:</span><br clear="none" style="font-family: monospace; font-size: 13px;"></div><div><div>&gt;&gt; Thank you for this, I never thought of doing that because I was expecting something like Version 2 would work just fine without any leaks.</div><div><br></div><div>But going back to the original problem, why is this causing a leak when all objects are declared as _var?</div><div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>m_NSObj = m_ORB-&gt;resolve_initial_references("NameService");</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>m_RootContext =
 CosNaming::NamingContextExt::_narrow(m_NSObj);</div><div>&gt;&gt; I think the LOCATION_FORWARD exception has something to do with this (upon "changing" location and retrying to resolve). &nbsp;I am still setting up my test environment so that no LOCATION_FORWARD exception will occur (or is this inevitable?, any suggestions on how to if not?) and see if it does not leak. &nbsp;I am using the "native" JAVA orb for the other end/server-side (both persistent and transient).</div><div><br></div><div>Thank you and I hope you stay with me to resolve this issue :) ...appreciate it!</div><div><br></div></div><div>Regards,</div><div>Miff</div></div></div><div class="yahoo_quoted" style="display: block;"> <br> <br> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2"
 face="Arial"> On Wednesday, December 11, 2013 7:50 PM, Duncan Grisby &lt;duncan@grisby.org&gt; wrote:<br> </font> </div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div class="y_msg_container">On Wed, 2013-12-11 at 15:10 +0800, Mifflin Mabalot wrote:<br clear="none"><br clear="none">&gt; Then if invocations on the new<br clear="none">&gt; location fail, omniORB retries with the original object reference.<br clear="none">&gt; That's important for various implementation repository approaches and<br clear="none">&gt; for object migration support.<br clear="none">&gt; <br clear="none">&gt; &gt;&gt; What happens if invocations on the new location succeed? Is the<br clear="none">&gt; original object reference "deallocated", I think this is what's<br clear="none">&gt; missing<br clear="none"><br clear="none">The original object reference is kept for as long as the application<br
 clear="none">code holds on to the object reference. The forwarded reference can fail<br clear="none">at any time, and if it does it reverts back to the original location.<br clear="none"><br clear="none">[...]<br clear="none">&gt; Whenever a remote object is referenced, that too is causing leaks, but<br clear="none">&gt; I found a way to cleanup the leaks by incorporating some extra code,<br clear="none">&gt; see below (maybe the "allocation for every reference" is by design and<br clear="none">&gt; is included in the CORBA specs, but I used a _var (smart pointer)<br clear="none">&gt; which has been discussed as "self-cleaning / self-deallocating" during<br clear="none">&gt; destruction, yet it is leaving behind leaks)<br clear="none"><br clear="none"><br clear="none">[...]<br clear="none">&gt; CORBA::WStringValue* l_sayHelloPtr = TaskWork.m_HelloObj-&gt;sayHello();<br clear="none"><br clear="none">You are responsible for releasing the WStringValue
 pointer. It's a leak<br clear="none">in your code, not in omniORB, if you don't release it.<br clear="none"><br clear="none">[...]<br clear="none">&gt; // Cleanup to avoid leaks (this simply releases a reference, so that<br clear="none">&gt; the object can clean/deallocate itself)<br clear="none">&gt; CORBA::WStringValue_Helper::remove_ref(l_sayHelloPtr); // &gt;&gt; NOT DOING<br clear="none">&gt; THIS WILL CAUSE LEAKS<br clear="none">&gt; }<br clear="none"><br clear="none">This is a non-standard way to release the pointer. You should call<br clear="none">_remove_ref directly:<br clear="none"><br clear="none">&nbsp; l_sayHelloPtr-&gt;_remove_ref();<br clear="none"><br clear="none">Or, probably better, use a _var that automatically calls _remove_ref<br clear="none">when it goes out of scope:<br clear="none"><br clear="none">&nbsp; CORBA::WstringValue_var l_sayHelloPtr = ...<div class="yqt0414505201" id="yqtfd17741"><br clear="none"><br clear="none"><br
 clear="none">&gt;&nbsp; &nbsp; &nbsp; &nbsp;  <br clear="none"><br clear="none">-- <br clear="none"> -- Duncan Grisby&nbsp; &nbsp; &nbsp; &nbsp;  --<br clear="none">&nbsp; -- <a shape="rect" ymailto="mailto:duncan@grisby.org" href="mailto:duncan@grisby.org">duncan@grisby.org</a>&nbsp; &nbsp;  --<br clear="none">&nbsp;  -- <a shape="rect" href="http://www.grisby.org/" target="_blank">http://www.grisby.org </a>--<br clear="none"><br clear="none"><br clear="none"></div><br><br></div> </blockquote>  </div> </div>   </div> </div></body></html>