CORBA - garbage collection of servants and client-side callback objects
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tiger_Smith
Posted On:   Tuesday, February 22, 2005 06:51 AM

I have two questions regarding garbage collection when using Java / CORBA 1. Server-side object / servant: ... ORB orb = ORB.init(args, null); POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); // create servant and register it with the ORB TaskServerImpl taskServerImpl = new TaskServerImpl(); taskServerImpl.setORB(orb); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(taskServerImpl); TaskServer href = TaskServerHelper.narrow(ref); // get the root naming context org.omg.CORBA.Object objRef=orb.resolve_initial_ref   More>>

I have two questions regarding garbage collection when using Java / CORBA

1. Server-side object / servant:

			
...
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();

// create servant and register it with the ORB
TaskServerImpl taskServerImpl = new TaskServerImpl();
taskServerImpl.setORB(orb);

// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(taskServerImpl);
TaskServer href = TaskServerHelper.narrow(ref);

// get the root naming context
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

// bind the Object Reference in Naming
NameComponent path[] = ncRef.to_name("TaskServer");
ncRef.rebind(path, href);
...


Question:
- How can I make TaskServerImpl and TaskServer available for garbage collection? Is it enought to call ncRef.unbind(...), or some rootpoa methods (like deactivate_object) have to be called as well?

- Does it matter if there are active client remote references to given servant - will this prevent garbage collection, or ORB/POA know nothing about it?

2. Callback on client:
			
...
// create and initialize the ORB
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();

SysoutMessageListener messageListener = new SysoutMessageListener();
rootpoa.activate_object(messageListener);

org.omg.CORBA.Object ref = rootpoa.servant_to_reference(messageListener);
MessageListener href = MessageListenerHelper.narrow(ref); ...


Question:
- How do I make messageListener available for Garbage collection? Is it enought to call rootpoa.deactivate_object(...)?

Many thanks in advance!    <<Less

Re: CORBA - garbage collection of servants and client-side callback objects

Posted By:   Anonymous  
Posted On:   Sunday, May 8, 2005 05:38 AM

Hi there, so sorry but this isn't an answer to your question... I did a search on the name Tiger Smith as it is my son's name and found the link to this forum and I would just like to know if this is your real name or just an online handle, and if so what made you come up with it? I understand if you don't reply, I am just fascinated that there is another Tiger Smith out there ; ) My Tiger is 18 months old and we thought the name would be unique!(ha ha). Thanks.

Re: CORBA - garbage collection of servants and client-side callback objects

Posted By:   Anonymous  
Posted On:   Tuesday, March 1, 2005 06:56 PM

How can I make TaskServerImpl and TaskServer available for garbage collection? Is it enought to call ncRef.unbind(...), or some rootpoa methods (like deactivate_object) have to be called as well? -


Yes, you'll need to call deactivate_object so it is removed from the Active Object Map.


Does it matter if there are active client remote references to given servant -


Depending on your application and policies, if a request is made for a deactivated object, the POA could reactivate the object, so you should make sure to call remove on the client side also, so the reference won't be used.


If there were active requests, the object would not be deactivated until completing the requests.


There's quite a bit of information in Advanced CORBA Programming with C++, including a discussion of garbage collection, the Pacific Ocean Problem, and the Evictor pattern.


Finally, here's a Python
example, but the ideas should be the same.

About | Sitemap | Contact