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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:32:43+00:00 2026-06-03T06:32:43+00:00

I have been trying to design a system in Java where I can track

  • 0

I have been trying to design a system in Java where I can track resources like Images and Audio files loaded from disk and unloading them when there are no references to it.

In C++ I could override the delete operator so I could decrement the reference.
But Java works with automatic garbage collection which destroys an object when it has no references.

Because I keep track of all the resources in my resourcemanager, the reference to the object will never be null, thus the resources will never be unloaded if they are not needed.

Is there a way to keep track of the objects while at the same time deleting them while they have no references from entities?

I have heard a deconstructor is not safe so that’s also not an option

  • 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-03T06:32:45+00:00Added an answer on June 3, 2026 at 6:32 am

    Use WeakRefence in your resourcemanager, e.g. a WeakHashMap.

    You can find a good explanation of WeakReferences (and other references e.g. Softreference) here: http://weblogs.java.net/blog/2006/05/04/understanding-weak-references

    Simple said:
    A weak reference is a reference that does not to force the object to stay in memory. If there is no strong reference to the object, but you still have the weak reference in your resourcemanager, the object is still eliglible for garbage collection and can be deleted by the garbage collector.

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

Sidebar

Related Questions

I have been trying to design a WCF file upload service and am getting
Have have been trying to make a validator for my xml files. I have
I am new to design patterns, but I have been trying hard to implement
I'm a developer with limited HTML/CSS design experience. I have been stuck trying to
I have recently been trying to learn about basic design principles and the OCP
I have been trying to subclass the UINavigationController class for modifying things like background
I have been trying very hard to achieve rounded corners with IE6+jquery ui tabs.
I have been trying to us CALayers as sprites in an iPhone application I'm
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I have been trying to find a code snippet to do an unsharp mask

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.