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

Avoid creating duplicate thread groups

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.1.2.Final, 6.0.0.Alpha1
    • 5.1.1.SP2
    • None
    • None

      In ContainerLifecycleEventPreloader constructor, new ThreadGroup with hardcoded name is created each time the ContainerLifecycleEventPreloader instance is initialized. (The preloader can be initialized repeatedly for instance during application container reload.)

      This creates a memory leak, although small in terms of memory, because created thread groups are never garbage collected. (There is a tree of created thread groups maintained in the ThreadGroup class which contains reference to every created group.)

          public ContainerLifecycleEventPreloader(int threadPoolSize, ObserverNotifier notifier) {
              this.executor = Executors.newFixedThreadPool(threadPoolSize,
                      new DaemonThreadFactory(new ThreadGroup("weld-preloaders"), "weld-preloader-"));
              this.notifier = notifier;
          }
      

      Can the created thread group instance be kept in a static field to avoid it being created repeatedly?

              manovotn Matěj Novotný
              thofman Tomas Hofman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: