title: Do we need clear MDC after HTTP request in Spring
body: <p>According to this answer <a href="https://stackoverflow.com/a/818120/1568605">thread local variable</a> when we use thread local we should clear all variable in thread pool environment.</p>
  
  <p>So basically I just want to <strong>confirm</strong> that when we are using MDC (Mapped diagnostic context) we also should clear MDC to aware memory leaks, is that true ?  </p>
  
  <p>So for instance :</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration
  public class WebConfig implements WebMvcConfigurer {
      public class HttpInterceptor implements HandlerInterceptor {
          @Override
          public boolean preHandle(final HttpServletRequest request,
                                   final HttpServletResponse response,
                                   final Object handler) {
              MDC.put(SESSION_ID, session_id);
          {
  
          @Override
          public void postHandle(final HttpServletRequest request,
                                 final HttpServletResponse response,
                                 final Object handler,
                                 final ModelAndView modelAndView) {
             MDC.clear(); //WE SHOULD CLEAR MDC.... if not memory leaks ?
          }
      }
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(new MdcHandlerInterceptor());
      }
  }
  </code></pre>