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

  • SEARCH
  • Home
  • 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 4012612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:16:09+00:00 2026-05-20T09:16:09+00:00

I have a data producer that produces data that is used by a number

  • 0

I have a data producer that produces data that is used by a number of a different consumers (let’s call them Cs). Each C has its own set of data that it’s interested in. The data producer has weak references to the Cs so they can be notified for updates.

Each C is also used by a number of independent components, so no single one component can tell when the C is no longer needed, so we have to leave it to the JVM to determine when C is GC-able.

The goal here is to be notified when a C becomes obsolete, so the data producer can turn off data that is only interesting to that unused C.

As I mentioned earlier, the data producer always has weak references to the Cs, so it’s easy to do it when a C is GCed. However, I noticed that the Cs usually stick around in the VM for an extended period of time before it’s finally GC-ed and all this while, the data producer is producing a LOT of data it should have needed to.

Is there any way for me to force the GC of unused Cs? I am hoping for yes, but I’m expecting a No, so as a follow-up question, does anyone have a good suggestion to how I can (re)design this to make it work better/more efficiently?

Thank you!!

Some answers below make a lot of good points – in particular the suggestion to force users of C to subscribe and unsubscribe. This is difficult because:

C is just one possible implementation of an interface I (which doesn’t have this subscription requirement), which is what the users really use. The C implementation is injected during run-time, so we can’t force the users to comply to C-specific requirements. (Ouch?)

  • 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-20T09:16:09+00:00Added an answer on May 20, 2026 at 9:16 am

    I’ll just go with System.gc();

    There’s some really interesting information in this related post:
    Java: How do you really force a GC using JVMTI's ForceGargabeCollection?

    Apparently a lot of IDEs use that too to evaluate the amount of available heap. Guess there’s no reason I can’t do that too.

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

Sidebar

Related Questions

We have a web application that produces reports. Data are taken from a database.
In my scenario, I have a program that analyzes data input files and produces
I have a util module that produces a jar to be used in other
I have some data (produced by a legacy application) that I know is invalid
I have data from travel diaries which has been read in from a csv
I have data-segment attribute in my body tag that is changed by a slider.
I have data that is mostly centered in a small range (1-10) but there
I have a C function that produces about 6 million unique arrays. These arrays
I have a thread which produces some data (a python list) and which shall
Here is the example that I have run. It has the same Mode, Padding,

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.