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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:48:12+00:00 2026-05-23T06:48:12+00:00

[EDIT]Problem solved, I found the leak. Thank you very much. I’m running a scheduling

  • 0

[EDIT]Problem solved, I found the leak. Thank you very much.

I’m running a scheduling algorithm, with nodes that stores the following data:

int job[] = new int[Algo.NUM_MACHINES];
int remTime[] = new int[Algo.NUM_MACHINES];
int res = Algo.RESOURCE;
int time = 0;
int tardy = 0;

//Job jobTree[] = new Job[Algo.NUM_JOBS];
ArrayList<Integer> jobsFinished = new ArrayList<Integer>();

int id;
boolean visited = false;
Machine parent = this;//so that root node points to himself
ArrayList<Machine> children = new ArrayList<Machine>();

int duplicate = 0;//duplicate (sj-sj-sj-sj-...) flag

Each node has an ArrayList that leads to its children, and a parent node that leads to its parent.

When I determine a node is no longer needed, is

node.parent.children.remove(node);
node.parent=null;

enough to cause the node be recycled? How would you write the code to recycle the node?

  • 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-23T06:48:12+00:00Added an answer on May 23, 2026 at 6:48 am

    To make an object recyclable in a garbage-collected environment, you have to ensure that there are no references to it from reachable objects.

    Garbage collection sees what objects are reachable by following references. When you overwrite a reference or set it to null, you’re burning a bridge to the target object, and if there’s no other way to get to that object, the memory can be reclaimed.

    As far as I can tell, you don’t need this line:

    node.parent=null;
    

    because node becomes unreachable when it’s removed from the ArrayList (unless there’s a pointer to it elsewhere in the application). If node is unreachable, it doesn’t matter what it points to because it’s already sunk.

    If nodes aren’t being collected, but you think they should be, try to find out what is pointing to them. It might even be a parameter or variable up in the stack somewhere keeping the memory pinned.

    Disclaimer: I don’t know Java, so I don’t know exactly how its VM works. I’m going by my knowledge of garbage collection in general.

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

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Edit : The bug that caused this problem has been fixed. The @version tag
THIRD EDIT: I now believe that this problem is due to a SOAP version
I was playing around with anonymous subclasses and I found a problem that I
I imagine this is common enough that it's a solved problem, but being a
I have looked around and have not found any answers that have solved the
EDIT I accidentaly found a walk around to this problem... Adding the following line
I finally solved one problem but now i have another. I found out how
edit: I was trying to solve a spoj problem. Here is the link to
[Edit: This problem applies only to 32-bit systems. If your computer, your OS 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.