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.

有帮助吗?

解决方案

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.

其他提示

Whenever you reference Corba object, it's internal reference count increases by one. This is similar to Java garbage collector mechanism.

That means that myObj will be garbage collected only when ior, href and ref are garbage collected.

There's also an option to manually decrease Corba reference count of myObj but this is not recommended because then you will defeat Corba's reference count mechanism and cause unpredictable behavior.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top