Issue 2309: Memory management of recursive value (cxx_revision) Source: (, ) Nature: Uncategorized Issue Severity: Summary: Summary: Section 20.21, "Argument Passing Considerations," says that for valuetypes: "The caller shall eventually invoked _remove_ref on the valuetype instance it receives back as either an inout, out, or return value." For memory management purposes, this is not sufficient in some cases. Resolution: Revised Text: Actions taken: January 20, 1999: received issue Discussion: deferred in June 2011 to the next RTF End of Annotations:===== From: mcheng@us.ibm.com X-Lotus-FromDomain: IBMUS To: issues@omg.org, cxx_revision@omg.org Date: Wed, 20 Jan 1999 11:45:28 -0600 Subject: memory management of recursive value Content-Disposition: inline Section 20.21, "Argument Passing Considerations," says that for valuetypes: "The caller shall eventually invoked _remove_ref on the valuetype instance it receives back as either an inout, out, or return value." For memory management purposes, this is not sufficient in some cases. Consider a circularly linked list: valuetype val { public val next; }; val * myVal = new ...; // initial ref count 1 myVal->next(myVal); // Introducing circular link to self, ref count now 2 If myVal were passed back to a caller, calling _remove_ref() merely decreases its ref count to 1, causing a memory leak. This leak can happen in the dispatcher to a method that returns a valuetype, or in the destructor of a struct/union/sequence that holds a valuetype member. Michael Cheng mcheng@us.ibm.com