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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:38:19+00:00 2026-05-27T19:38:19+00:00

I created a graph that contains nodes and arcs. When I close the SWING

  • 0

I created a graph that contains nodes and arcs. When I close the SWING application and manually update the structure of a graph (i.e. remove some nodes and arcs), the old structure of the graph is not deleted from the memory.
For instance:

ArrayList<Node> nodes = new ArrayList<Node>();
ArrayList<Arc> arcs = new ArrayList<Arc>();
nodes.add(new Node("N1"));
nodes.add(new Node("N2"));
nodes.add(new Node("N3"));
arcs.add(new Arc("N1","N2"));
arcs.add(new Arc("N2","N3"));
Graph g = new Graph(nodes,arcs);

In the Node class I have:

@Override
public String toString() {
    return super.toString() + 
           (isNotConnected() ? " IS NOT CONNECTED" : "" );
}

Then I close the application, remove the node “N3” and arc (“N2″,”N3”) and run the application again. It says that N3 IS NOT CONNECTED. But I deleted N3!!!
To close the application, I´m using:

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

Also, I tried to use g = null, but it didn´t help as well.

UPDATE:

public class Node {
    private List<Arc> incoming = new ArrayList<Arc>();
    private List<Arc> outgoing = new ArrayList<Arc>()

    protected Node(String name) {
        super(name);
    }

// ...

    public boolean isNotConnected() {
        return incoming.isEmpty() && outgoing.isEmpty();
    }

    public void addIncoming(Arc arc) {
        this.incoming.add(arc);
    }

    public void addOutgoing(Arc arc) {
        this.outgoing.add(arc);
    }

}
  • 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-27T19:38:20+00:00Added an answer on May 27, 2026 at 7:38 pm

    It’s very unlikely that anything is “not deleted from the memory“—each new run is a new JVM, and it means absolutely clean sheet, no history from the previous run.

    So I’d rule this possibility out. What’s left then?

    • You can have a bug in the isNotConnected() method — not likely, as I hope you got the super.toString() right.
    • You can have an older code running. It can be easily diagnosed by changing any string you print, e.g. going from “NOT CONNECTED” to “not connected” — no change in logic, but easy to spot in the logs.
    • You can have one more point in the code where you create N3
    • Etc, etc.

    What’s important here is that you should never blame the magical non-cleaning memory before you have ruled out all other possibilities.

    Have fun!

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

Sidebar

Related Questions

I know that Matlab allows for you to format the graph after its created
I got the Flot-created graph. What I wanted to acomplish is to get some
Given a graph of n nodes that are all interconnected on a coordinate plane,
If I have large object graph that contains many duplicate strings, is there a
I have a object that is created through deserialization of some XML. I used
UPDATE: I found the answer... included it below. I have a dataset that contains
All of our reports are created from object graphs that are translated from our
I have a graph created with MS Chart like the following picture. As you
I am creating a Facebook application that will download all the photos in an
I have the requirement to create a page which contains a graph at the

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.