The rule for proper CORBA memory management is that the caller owns all of the storage.
Memory management in Java code is somewhat automatic.
The general model for CORBA C++ memory management on the client is to use _var objects. This means that when an _ptr is returned, it must be placed into an _var by the client. The _var assumes responsibility for the storage pointed to by the _ptr that is placed into the _var. The _var is a class and its destructor runs when the _var goes out of scope.
The other option for CORBA C++ clients is to use the duplicate() and release() methods. The duplicate() method is available for making a copy of a client stub object, while the release() method is used to free the local memory used by a pointer.
For more reference information about CORBA C++ memory management, see the topic, "CORBA programming: Storage management and _var types".
Managing the storage of object references
Managing the storage of object references is one of the areas where proper memory management is required. You must use use _var variables or the duplicate() and release() methods as stated previously.
There are also special considerations when passing object references as parameters. The caller is always responsible for allocating storage for object references. The caller also is responsible for releasing of all inout and returned object parameters.
For inout parameters, the caller provides an initial value. If the receiver wants to reassign the inout parameter, it must call the release() operation on the initial input value. To continue to use an object reference passed as an inout, the caller first must duplicate the reference.