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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:18:00+00:00 2026-06-18T23:18:00+00:00

I have a doubly linked list of objects: class MyObject { MyObject previousObject; MyObject

  • 0

I have a doubly linked list of objects:

class MyObject {
  MyObject previousObject;
  MyObject nextObject;

  // Other fields and methods
}

Only the first object of such a list is directly stored in the application, the other objects are reached through this first object and temporarily used in the application (but no permanent references are kept outside the list itself).

When one does not refer to an object anymore, it is collected by the Garbage Collector.

But, I was wondering whether this is still the case, because the (first) object is still being referenced by the ‘next object’ in the linked list? And what about the rest of the list, are those objects also collected (even though being referenced by each other)?

Note: I know that I could remove all references in the list when I do not use it anymore. But this is ‘hard’ due to the nature of the application and results in additional (unnecessary?) overhead.

  • 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-18T23:18:01+00:00Added an answer on June 18, 2026 at 11:18 pm

    The GC doesn’t use reference counting, so circular dependencies are handled just fine. You don’t need to do anything, and the whole list will be garbage collected when no element of the list is reachable anymore.

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

Sidebar

Related Questions

I have an assignment that requires us to implement a doubly linked list class.
Suppose I have a doubly-linked list that has a pointer to the first node
I have tried to implement doubly linked list in C++. Here is the code,
I have been working with a doubly linked list. Everything works OK with the
this is my whole class ,I have added number 2 to the doubly linked
I am trying to implement a Circular Doubly Linked List, and I have no
I have a code of doubly Linked list and there are few lines of
Gurus, I have difficulty to pass an arraylist of doubly-linked list as a parameter.
Lets say you have 2 classes: - Node - Doubly linked list (DLL) Your
I got a problem here, implementing a Sorted Doubly Linked List of first 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.