![]() |
The rule for proper CORBA memory management is that the caller owns all storage.
Memory management in Java is somewhat automatic.
The general model for C++ CORBA memory management on the client is to use _var objects. This means that when an _ptr is returned, it should 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 C++ CORBA 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 C++ CORBA memory management, see 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 above.
There are also special considerations when passing object references as parameters. The caller is always responsible for allocating storage for object references. The caller is also responsible for releasing of all inout and returned object references.
For inout parameters the caller provides an initial value. If the callee wants to reassign the inout parameter, it must first all the release() operation on the initial input value. To continue to use an object reference passed as an inout, the caller must first duplicate the reference.
Related concepts... | |
Parent: The CORBA client programming model | |
The CORBA programming model | |