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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:42:30+00:00 2026-05-12T05:42:30+00:00

My developers and I are having an issue with objects being garbage collected in

  • 0

My developers and I are having an issue with objects being garbage collected in our application when we don’t want them to be. We are using Java with Weblogic 10g3. We are programming a singleton pattern to handle all of our JMS connections.

There are two classes involved:

public class JMSObject {
...
private MessageProducer _producer;
private MessageConsumer _consumer;
...
// standard get/set procs... etc.
}

public class JMSFactory {
...
// Hashmap sessions with key == ConnectionFactory Name
    Hashmap<String, List<Session>> _sessions;

// Hashmap of JMSObjects with key == ConnectionFactory Name + JMS Queue Name
    Hashmap<String, List<JMSObject>> _jmsobjects;
...
// standard get/set & necessary sington functions
}

The init method of the Servlets calls the JMSFactory singlton method, any new Sessions are placed in the _sessions Hashmap and new MessageConsumer/MessageProducers are created as a JMSObject and placed in the _jmsobjects Hashmap, in the appropriate List.

The problem is that when the system is running the JMSObjects in the list get garbage collected after some time (sometimes in 5 minutes other times after a few hours.) We looked at this for a few days but could not find any reason for the JMSObjects to be garbarge collected. Since the JMSFactory has a reference to them why would the gc destroy them?

In the end we fixed it by changing the classes as follows(without changing method interfaces):

public class JMSObject {
...
private List<MessageProducer> _producers;
private List<MessageConsumer> _consumers;
...
// standard get/set procs... etc.
}

public class JMSFactory {
...
// Hashmap sessions with key == ConnectionFactory Name
    Hashmap<String, List<Session>> _sessions;

// Hashmap of JMSObjects with key == ConnectionFactory Name + JMS Queue Name
    private Hashmap<String JMSObject> _jmsobjects;
...
// standard get/set & necessary sington functions
}

So far in testing the JMSObjects are not being gc’ed. It has been running for 2 days.

Can someone explain why the indirect reference is causing the JMSObject to get gc’ed? And why the Sessions in the _sessions Hashmap was not getting gc’ed? Does it have anything to do with the fact the Sessions are built in Javax types and the JMSObject is something we wrote?

  • 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-12T05:42:31+00:00Added an answer on May 12, 2026 at 5:42 am

    I think I know what your problem is, it’s something I ran into a while back (on WebLogic 6). I believe it has to do with WebLogic’s dynamic class reloading, which WebLogic seems to do from time to time, even when you’re not in a development environment (I’m guessing the web.xml is somehow getting touched by some service or something).

    What happened in our case was that like you, we have a single instance of an object that’s defined as a static variable of some class, and just like you, it’s initialized by a servlet that has it’s load-on-startup parameter set. When WebLogic thinks there’s a change, it reloads the webapp by garbage collecting the classloader (which is fine) but it doesn’t re-initialize all the servlets that are marked “load-on-startup” (in our case, and I’m guessing yours, the servlet serves no purpose other than to initialize the static variable, there are no mappings to it, and so it cannot be invoke, the static variable gets GCed, but not-reinitialized, and the server needs to be restarted.

    In our case, our solution was to initialize the static variable in a static initializer. The original developer used a servlet to initialize the variable because he wanted some servlet context information, which really wasn’t necessary. If you need context information, you could try doing your initialization in a ServletContextListener.

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

Sidebar

Ask A Question

Stats

  • Questions 149k
  • Answers 149k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Views are used for displaying information. What you're describing belongs… May 12, 2026 at 9:36 am
  • Editorial Team
    Editorial Team added an answer The first thing that happens when the NSXMLParser encounters an… May 12, 2026 at 9:36 am
  • Editorial Team
    Editorial Team added an answer Try TACO HTML Edit or JEdit (Freeware) Bye. May 12, 2026 at 9:36 am

Related Questions

This question has been puzzling me for a long time now. I come from
WARNING: LONG QUESTION. [QUESTION] If the strategy is to have a branch per database,
I'm having a weird problem on deployment while trying to use Microsoft Enterprise Library's
I was watching Rob Connerys webcasts on the MVCStoreFront App, and I noticed he
I'm looking for a free/open source collaborative project manager that can be deployed internally

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.