javacorbajacorb

Discard a servant from CORBA after calling "servant_to_reference"


The following sequence gives me an IOR and keeps the MyObj instance somewhere inside CORBA (JacORB) so that the IOR can be used at a later stage:

MyObj myObj = new MyObj(); 
org.omg.CORBA.Object ref = poa.servant_to_reference(myObj); 
org.omg.CORBA.Object href = MyObjHelper.narrow(ref); 
String ior = orb.object_to_string(href); 

Can I somehow tell JacORB to discard "myObj" (at a later stage, of course)? References are kept forever in some Hastable (inside JacORB), and when creating a lot of entries, a wild OutOfMemory appears at some point. I want JacORB to forget about my object when I tell it to.


Solution

  • The first thing that you can do is deactivate unused servants, *poa.deactivate_object()*. The problem is know when the servant can be deactivated.

    The best ideia is implement ServantManager with some timeout policy.

    Don't forget about POA policies.