ORBit Beginners Documentation V1.2 | ||
---|---|---|
<<< Previous | How to do garbage collection under CORBA | Next >>> |
Elliot Lee, ever the prescient one, asked:
"Object or object reference? "
And then observed:
"I think Todd is confused as to what the difference between object references and objects is. Think of an object reference and an object as being analogous to a pointer and pointed-to memory, respectively. You can stop using a pointer, but until you get the server side to actually free() the memory (object) being pointed to (referenced), it is still there. "
Indeed I was confused. There are actually two processes which occur within CORBA:
the client drops all references to an object, after which the ORB local to the client then can clean up all of its data structures related to that object, and
the server can decide that the object needs to be destroyed, and it then does the job of deactivating the object (so that the POA can know not to answer any more queries to that object) and freeing associated resources, etc.
Since object references can be generated in one program, passed to a second program, the first program can forget about it, and the second can continue, these are separate processes. It was understanding this fact which was the biggest impediment to my figuring this matter out.
Sascha Brawer <brawer@coli.uni-sb.de> described these two potential interpretations of what I wanted to do, reflecting a nuance which I did not appreciate when I asked the question:
You want the client to forget about the object reference, but the server-side object should continue its life: Call CORBA_free on the client side. The purpose of CORBA_free is to release the memory in the client. Therefore, the server will not get any notification about this. If other clients had references to the same object, they will continue to work.
You want to destroy the object on the server: define a method in the object's interface, e.g. "destroy" (though any name is fine). First, call that method on the client side. The server will receive the call, and your server implementation will destroy the object. Second, call CORBA_free on the client side, to free the client-side memory for the object reference which has now become stale. If other clients had references to the same object, they will receive an exception as soon they call a method on that object. However, they won't be notified in advance, because the server does not keep track on issued references.
Which Elliot Lee then corrected with:
CORBA_Object_release() on object references, CORBA_free() on data structures.
Dick Porter added:
It is _only_ the client side. These pseudo-object methods do not cause requests to be made to the server.
<<< Previous | Home | Next >>> |
How to do garbage collection under CORBA | Up | Server-side deactivation |