Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7981383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:21:09+00:00 2026-06-04T10:21:09+00:00

i’m using the thread locals approach to have a json serializer per each application

  • 0

i’m using the thread locals approach to have a json serializer per each application thread to avoid the object creation each time i want to serialize it.

The code i’m using the following code:

public class JsonSerializerFactory {
    private static final ThreadLocal<JsonSerializer> JSON_SERIALIZER = 
        new ThreadLocal<JsonSerializer>() {
        @Override 
        protected JsonSerializer initialValue() {
             return new JsonSerializer();
        }
    };

public static JsonSerializer get() {
    return JSON_SERIALIZER;
}

}

each time i want to get the serializer i do:

JsonSerializerFactory.get()

When i’m shutting down the tomcat i see the following logs:

May 23, 2012 9:15:25 AM org.apache.catalina.loader.WebappClassLoader     clearReferencesThreads SEVERE: The web application [] appears to have started a thread named [Logback AsyncAppender Dispatcher [Async_Logger] - Thread-16] but has failed to stop it. This is very likely to create a memory leak.

I’ve read the Tomcat memory leak protection but i probably missing something there.
Do I really have a leak, or should I ignore this message?

Could someone please explain?

see how to enhance tomcat thread pool behaviour

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:21:10+00:00Added an answer on June 4, 2026 at 10:21 am

    Every time you use a ThreadLocal you should really have some way to clear it up. What tomcat is complaining about is that the thread created internally by logback has referenced this thread local and there for it won’t be collected (assuming that thread doesn’t die).

    You can probably ignore this message if:

    • Hot application reloads are not that important, its only a leak if you reload the app
    • You know that the logback thread finishs when the application stops

    What you might want to think about is whether or not you need a ThreadLocal cache in the first place. Is that JsonSerializer really that expensive? are you certain it isn’t thread safe.

    public class JsonSerializerFactory {
        public static JsonSerializer get() {
            // do this until you know you have a problem.
            return new JsonSerializer();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.