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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:03+00:00 2026-05-26T10:12:03+00:00

I have a User object which strongly refers to a Data object. If I

  • 0

I have a User object which strongly refers to a Data object.

If I create a Map<Data, User> (with Guava MapMaker) with weak keys, such a key would only be removed if it’s not referenced anywhere else. However, it is always refered to by the User object that it maps to, which is in turn only removed from the map when the Data key is removed, i.e. never, unless the GC’s circular reference detection also works when crossing a map (I hope you understand what I mean :P)

Will Users+Datas be garbage collected if they’re no longer used elsewhere in the application, or do I need to specify weak values as well?

  • 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-26T10:12:03+00:00Added an answer on May 26, 2026 at 10:12 am

    The GC doesn’t detect circular references because it doesn’t need to.

    The approach it takes is to keep all the objects which are strongly referenced from root nodes e.g. Thread stacks. This way objects not accessible strongly (with circular references or not) are collected.

    EDIT: This may help explain the “myth”

    http://www.javacoffeebreak.com/articles/thinkinginjava/abitaboutgarbagecollection.html

    Reference counting is commonly used to explain one kind of garbage collection but it doesn’t seem to be used in any JVM implementations.

    This is an interesting link http://www.ibm.com/developerworks/library/j-jtp10283/

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

Sidebar

Related Questions

I have a script which creates a user-defined object like this: obj = new
Suppose I have a user defined type: CREATE OR REPLACE TYPE TEST_TYPE AS OBJECT
I have a user object which is using pfc services. Now, during update, how
I have a page which is strongly typed to my User class. When it
I have a user object which contains information about the user (username, ip, country,
I Have a Strongly typed user control which i use for Searching a certain
I have a User object which has a collection of Transaction objects under it.
I have an object ( User ) which is not marked as [Serializable()] .
Say I have a User object, which is generated by a Usermapper . The
I have a User table which has a foreign key to the UserType table.

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.