Log4cxx
  1. Log4cxx
  2. LOGCXX-117

Memory leak with ThreadSpecificData on Win32

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win32

      Description

      I use the VLD (visual leak detector) with my applications and log4cxx and noticed quite some memory leaks. Well, in my specific application a huge number of threads might be spawn in the course of time. Is there a way to get rid of the ThreadSpecificData again? My application runs on Win32, and so the APRInitializer::tlsDestruct() won't be called.
      Consequently I've patched log4cxx by introducing a method to explicitly free the ThreadSpecificData, but that's of course not transparent. Is there an intend to provide the same behaviour of the APR for Win32 eventually? Any other ideas about that problem?

      Call freeCurrentData() just before your thread terminates in order to free the thread specific data.

        Activity

        Hide
        Curt Arnold added a comment -

        Rev 628179 reworked MDC, NDC and ThreadLocalData so that the ThreadLocalData object is reclaimed when the stack and map backing the NDC and MDC become empty and that no memory is allocated unless the user places something in either the MDC or NDC. If items are left in the NDC or MDC when the thread dies, the memory will not be reclaimed. Using the NDC and MDC constructors to place data can be used to ensure that the data is cleared on thread death.

        Show
        Curt Arnold added a comment - Rev 628179 reworked MDC, NDC and ThreadLocalData so that the ThreadLocalData object is reclaimed when the stack and map backing the NDC and MDC become empty and that no memory is allocated unless the user places something in either the MDC or NDC. If items are left in the NDC or MDC when the thread dies, the memory will not be reclaimed. Using the NDC and MDC constructors to place data can be used to ensure that the data is cleared on thread death.

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Kriz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development