MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-1443

StreamingAddResource introduces memory leak

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.7
    • Fix Version/s: 1.1.10
    • Component/s: None
    • Labels:
      None

      Description

      org.apache.myfaces.component.html.util.StreamingAddResource creates a Thread named CleanupThread. This causes a memory during development when an application is uninstalled/installed during development.
      The thread is unmanaged to the server and will hold references to the application classloader, even if the application is uninstalled from the server.

      The same problem will occur in production environments that use hot deploy features.

      I don't know if this does also affect 1.2.x stream.

      Suggestion: Please include a shutdown hook that can be used to stop the thread during application shutdown (via ContextLoaderListener or similar).

        Activity

        Hide
        Leonardo Uribe added a comment -

        I have attached a proposal to this one.

        The idea is create two classes: StreamingDestroyerListener and StreamingThreadManager. The first one is used to init and destroy the second one. StreamingThreadManager will be responsible to have all HeaderInfoEntry instances and init and destroy the cleanup thread.

        It is necessary to do some changes, introduce a new abstract class called AddResource2 that implements AddResource interface with an alternate method responseStarted(Object context, Object request), so we can retrieve the StreamingThreadManager instance from context object.

        I think we can take advantage of jdk 1.5 features (use AtomicLong instead a synchronized block) but for now it is better to keep things simple.

        Suggestions are welcome. If no objections, I'll commit this code, but I'll let some time before that. This bug affects core12 and core20, but after commit on core module, the code will automatically transferred to core12 and core20 (because thanks to myfaces builder plugin unpack goal, we can share code for all branches!)

        Show
        Leonardo Uribe added a comment - I have attached a proposal to this one. The idea is create two classes: StreamingDestroyerListener and StreamingThreadManager. The first one is used to init and destroy the second one. StreamingThreadManager will be responsible to have all HeaderInfoEntry instances and init and destroy the cleanup thread. It is necessary to do some changes, introduce a new abstract class called AddResource2 that implements AddResource interface with an alternate method responseStarted(Object context, Object request), so we can retrieve the StreamingThreadManager instance from context object. I think we can take advantage of jdk 1.5 features (use AtomicLong instead a synchronized block) but for now it is better to keep things simple. Suggestions are welcome. If no objections, I'll commit this code, but I'll let some time before that. This bug affects core12 and core20, but after commit on core module, the code will automatically transferred to core12 and core20 (because thanks to myfaces builder plugin unpack goal, we can share code for all branches!)

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Philipp Schoepf
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development