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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:54:30+00:00 2026-06-04T05:54:30+00:00

In my java application, when I close an opened model, some objects are not

  • 0

In my java application, when I close an opened model, some objects are not getting garbage collected. I am using Eclipse MAT to detect the paths to GC root and making sure that the references are set to null after model close so that GC can clean up the memory.

I am not able to clear the following references (an excerpt from Eclipse MAT output).

myTree javax.swing.JTree
   uiTreeExpansionListener, keyListener, focusListener javax.swing.plaf.basic.BasicTreeUI$Handler
         pressedPath javax.swing.tree.TreePath
            lastPathComponent myClass

If the myTree (JTree) does not reset/clear the value in the listeners, then a reference is maintained in lastPathComponent to an object of myClass and it is not garbage collected.

Any idea on how to tell the tree to not maintain references?

Edit: I have put the following method to clear the references, but it does not clear all (the above mentioned) the references.

    public void clear() {
        cancelEditing();
        collapseAll();
        clearSelection();
        clearToggledPaths();
        resetKeyboardActions();
        fireTreeCollapsed(null);
    }
  • 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-04T05:54:31+00:00Added an answer on June 4, 2026 at 5:54 am

    I found a workaround (not a clean and elegant solution) to at least take care of my problem. The following code does the job of releasing all the (known) references.

    public void clear() {
       cancelEditing();
       clearSelection();
       clearToggledPaths();
       resetKeyboardActions();
       updateUI();
    }
    

    Since I need to execute the above method when I close the model, the performance may not suffer much. But I would prefer a more elegant (and conceptually correct) solution if possible.

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

Sidebar

Related Questions

I am trying to detect when the Java application is about to close so
Writing a Java application using the Play framework and need some HTTP-Live streaming. I
In my Java application, I need to connect to the same host using SSL,
i'm developing a java application using the jstun library (hxxp://jstun.javawi.de/), and i need to
I have a java-application using JDBC for database interaction. I want to do a
I tried decompiling a Java application to which I do not have the source
How would I make my Java application delete itself and then close out of
I have a java application that will run on Windows 7 (using Swing, App
I have a java application which I have implemented its' database connection using singleton
Creating this application has become a pain in the ass! Using Java I want

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.