Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-920

Memory leak through the creational context of an @AppScoped bean when injecting Instance<>

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 1.1.0.CR3, 1.1.1.Final
    • Fix Version/s: None
    • Component/s: Scopes & Contexts
    • Labels:
      None

      Description

      Given a simple dependent-scoped bean: public class InstanceBean {}, and an application-scoped bean (see below) to which an instance of the dependent-scoped bean is injected, each time the get() method is called on the instance, even though it's not used, a reference to it stays in the creational context of the application scoped bean (http://screencast.com/t/XqjQ1GB7Wv3). That way after several requests, where each one calls the method, more and more memory is leaked (http://screencast.com/t/s1VBx49i).

      Attached is a simple web application demonstrating this. To reproduce, deploy to AS6, click the "leak" button several times, and analyze the heap dump e.g. in JProfiler.

      @ApplicationScoped
      @Named("test")
      public class AppScopedBean {
      private Instance<InstanceBean> instanceBeanInstance;

      @Inject
      public AppScopedBean(Instance<InstanceBean> instanceBeanInstance)

      { this.instanceBeanInstance = instanceBeanInstance; }

      public AppScopedBean() {
      }

      public void leakOneInstance()

      { System.out.println("Leaked!"); instanceBeanInstance.get(); }

      }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jharting Jozef Hartinger
                  Reporter:
                  adamw Adam Warski
                • Votes:
                  3 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: