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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:46:48+00:00 2026-06-07T17:46:48+00:00

Well, I have developed a java application using several objects relationships that make the

  • 0

Well, I have developed a java application using several objects relationships that make the memory usage too expensive. I have no experience managing the java memory because the application design make it difficult to destroy objects and re utilize the space previously cleared. For example, I am using Observer and MVC patterns.

So, the theory say that..

An Object becomes eligible for Garbage collection or GC if its not
reachable from any live threads or any static reference

In other words you can say that an object becomes eligible for garbage collection if its all references are null.

But, in my short experience, has be too difficult for me destroy all references from objects that I want to remove from memory (for example, when a frame is closed) when you have a scenario like mine, where you don’t know how many references to your classes exists.

According to this context, how can I deal with object destruction when there are multiple references to it? or how do I need to manage the memory when you have a complex references to each others?

  • 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-07T17:46:50+00:00Added an answer on June 7, 2026 at 5:46 pm

    Keeping Track

    According this context, how can I deal with object destruction when there are multiples references to it?

    By making sure these references are not needed anymore.

    If you isolate them, even in a big isolated graph of unused objects not connected anymore to your main progam, then they are all eligible for garbage collection.

    Local variables which have reached the end of their scope will be eligible for garbage collection (and so will their contained) objects, if they have not been “linked” to anything else (added to a collection, ac omposite, etc…). For UI objects, which can indeed be difficult to reason with in terms of object graphs, make sure to dispose of them correctly or to read the documentation to make sure that they would naturally disposed of.

    Simplified View of Reference Counting in the JVM

    “Leave [GC] Alone!!”

    or how do I need to manage the memory when you have a complex references to each others?

    You can’t “manage” the memory. You can simply manage references. The idea is to “severe” your connections to your objects by simply not having references to them. They then live up in memory until the GC exterminates them.

    Do not attempt to mess with the GC to force it to do things. It’s a rather clever beast, and while you can try to instruct it to react to some requests explicitly – it might ignore you – it’s usually a bad idea: do not invoke the GC explicitly, avoid finalizers and explicit nulling if you don’t understand their implications.


    Note to answer your comment

    Simply nulling a reference to an object that has been added to several collections or composites will not make it eligible for collection. By doing this, you’d have only nulled one reference.

    You do need to remove this object from all the lists or containers that have a reference to it (basically, making them “forget” about this object). Once no objects still “remembers” or has a “link” to your created object, it becomes a lonely item in the Garbage Collector’s graph, which makes it a candidate for deletion.

    Maybe it sounds tedious, but if you think of it from a language where you manually manage memory (C or C++, to name the most 2 obvious references), free-ing and null-ing pointers to your dynamically allocated objects would indeed destroy them, but you’d still need to remove the element from the lists (or any containers) or they would appear like empty buckets to a null pointer.


    Further Reading

    • Garbage Collection (especially the section on reachability)
    • Sun Microsystems’s Whitepaper on in the Java HotSpot Virtual Machine (dated, but very good)
    • Java Theory and Practice: A Brief History of Garbage Collection – How does Garbage Collection Work?
    • Java Theory and Practice: Garbage Collection Performance
    • How Garbage Collection Works in Java
    • Handling Memory Leaks in Java Programs
    • From Java Code to Java Heap
    • These SO questions on:
      • Java Memory Explained (provides a lot of additional info and links)
      • Java Memory Management Best Practices
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an application using postgresql and it works well. Now I need
I have developed an web application using xhtml, jQuery, Ajax, java, Servlets & tomcat
I have a well-developed application for a phone, but I would like to add
well I have that problem, im using a lightbox srcipt and im opening an
I have developed a Java Swing application, which uses the SwingWorker class to perform
I have developed a java program that runs fine in Mac OS X (10.6.7).
I have developed and Simple android application in Java and also uploaded it on
In my gwt application somebody developed a module which uses java.beans.PropertyChangeSupport. Recently I have
We have developed SOA architecure for our intranet application, so our web-start java applications
Well i have a div tag that i show as a modal dialog this

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.