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 7088217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:46:18+00:00 2026-05-28T07:46:18+00:00

I know that this problem has been around for at least 3 yeears (

  • 0

I know that this problem has been around for at least 3 yeears (Issue 92), but I’m still not satisfied with the current state of it. I am also aware that this does not affect Tomcat if you do restart after redeploying (as suggested in Guice + Tomcat potential memory leak).

My problem is that I am experiencing OutOfMemoryError: PermGen errors after some redeployments. Notice that I am not using google-collections explicitly, I am only using Guice 3.0 (via maven). After analyzing heap dumps, I still see that the thread com.google.inject.internal.Finalizer is still active, keeps a reference to Tomcat’s WebappClassLoader, thus hindering garbage collection.

What if I actually require redeployments without restarting and am using Guice? What are my options?

  • 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-05-28T07:46:19+00:00Added an answer on May 28, 2026 at 7:46 am

    Well, no one was there to help me, so here’s what I learned:

    The Finalizer thread is started by the FinalizableReferenceQueue (FRQ). There is a hard (static) reference to the FRQ in MapMaker. The WebAppClassLoader was not garbage collected because MapMaper was still around due to the hard reference.

    The following code solved my problem:

    final Class<?> queueHolderClass = 
        Class.forName("com.google.inject.internal.util.$MapMaker$QueueHolder");
    final Field queueField = queueHolderClass.getDeclaredField("queue");
    // make MapMaker.QueueHolder.queue accessible
    queueField.setAccessible(true);
    // remove the final modifier from MapMaker.QueueHolder.queue
    final Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(queueField, queueField.getModifiers() & ~Modifier.FINAL);
    // set it to null
    queueField.set(null, null);
    

    Here’s the offending code (com.google.inject.internal.util.MapMaker):

    /** Wrapper class ensures that queue isn't created until it's used. */
    private static class QueueHolder {
      static final FinalizableReferenceQueue queue = new FinalizableReferenceQueue();
    }
    

    After doing this, the Finalizer thread gracefully dies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this has already been asked here but the answer (using a
I know that this has been asked a million times before, but nothing that
I know this has been asked many times, but not quite the way I'm
This just won't work. The problem is that I do not know enough to
I know that this is subjective and all, but still, can you provide some
I know this question has been asked in several variations before, but my question
I apologize if this has been asked before. I searched but did not find
I know this question has been asked but I haven't found any satisfactory answers.
Have youI know that the problem has been many times discussed in the web.
I know that this is somewhat subjective, but I wonder if there is a

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.