2

I have a OSGi Java 8 project running with iPojo 1.12.1
I use Factories to create InstanceManager via the createComponentInstance method. Once I'm done with the InstanceManager I call dispose on it. I would expect the memory to be released, but the object still has a strong reference to it from other iPojo objects.

Factory myFactory; // Get the factory
InstanceManager instance = (InstanceManager) myFactory.createComponentInstance(null); // Get an instance
Object myObject = instance.getPojoObject(); // Retrieve the actual object
// Do something with the object.
myObject = null; // remove all reference to the object
instance.dispose(); // Dispose of the instance manager.
instance = null; // Remove my strong reference to the instance.


Is there anything I'm missing for the cleanup?

jct
  • 84
  • 5
  • First, except if you are in specific cases, you should not use `getPojoObject`. You can tell me who still have a strong reference ? – Clement Apr 24 '15 at 05:55
  • I have tried with both getPojoObject() and createPojoObject(). Both create the same problem. The strong reference that stays is on m_instance of org.apache.felix.ipojo.handlers.dependency.Dependency. This seems to happen when the InstanceManager that I'm creating is for a iPojo object that contains a Requires or Bind annotation to another iPojo – jct Apr 24 '15 at 13:50
  • @Clement how are we supposed to get a service using factories if not via `getPojoObject()`?? i thought that was the only way – Hilikus Apr 27 '15 at 14:17
  • You should then rely on the services exposed by the instance. See http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/how-to-use-ipojo-factories.html#accessing-services-exposed-by-created-instances – Clement Apr 29 '15 at 07:52

0 Answers0