title: Memory Leak / ContextInjectionFactory / IEclipseContext
body: <p>I am using dependency injection (DI) inside an Eclipse RCP application. I have a lot of classes that perform code similar to below:</p>
  
  <pre><code>public class SomeClass {
      @Inject
      private IEclipseContext context;
  
      private SomeObject void someMethod(){
          SomeObject someObject =
              ContextInjectionFactory.make(SomeObject.class, context);
          // Do stuff with someObject
      }
   }
  </code></pre>
  
  <p>When I monitor the application using jvisualvm, I notice there is a memory leak due to this.  The EclipseContext object keeps growing until it eventually runs out of memory.</p>
  
  <p>If I do the following, the memory leak goes away:</p>
  
  <pre><code>public class SomeClass {
      @Inject
      private IEclipseContext context;
  
      private SomeObject void someMethod(){
          IEclipseContext childContext = context.createChild();
          SomeObject someObject =
              ContextInjectionFactory.make(SomeObject.class, childContext);
          childContext.dispose();
          // Do stuff with someObject
      }
   }
  </code></pre>
  
  <p>I have not seen any documentation that supports doing my workaround.  Is there any negative side effects to disposing the childContext after the class is created?  Is there a better approach overall when using CIF that I haven't encountered? </p>
  
  <p>For what it's worth, my code has many classes, some of which are annotated with @Singleton / @Creatable. I'm not sure if these would be effected by a disposed parent context.</p>
  
  <p>Thanks!</p>