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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:12:31+00:00 2026-06-18T14:12:31+00:00

I have done some research on the java garbage collector and understand that an

  • 0

I have done some research on the java garbage collector and understand that an object who is no longer referenced will/should be handled by the garbage collector. In terms of arrays-of-objects, I am aware that assigning a new object to a location in the array does not properly deallocate the previously allocated object.

  1. I would like to know how to remove and properly deallocate an object from an array at location x and assign a new object to the same array at location x.
  2. I would also like to know how to properly deallocate the array itself.
  • 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-18T14:12:32+00:00Added an answer on June 18, 2026 at 2:12 pm

    Setting an object in an array to null or to another objects makes it eligible for garbage collection, assuming that there are no references to the same object stored anywhere.

    So if you have

    Object[] array = new Object[5];
    Object object = new Object() // 1 reference
    array[3] = object; // 2 references
    array[1] = object; // 3 references
    
    
    object = null; // 2 references
    array[1] = null; // 1 references
    array[3] = new Object(); // 0 references -> eligible for garbage collection
    
    array = null; // now even the array is eligible for garbage collection
    // all the objects stored are eligible too at this point if they're not
    // referenced anywhere else
    

    The garbage collection rarely will reclaim memory of locals though, so garbage collection will mostly happen already outside of the scope of the function.

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

Sidebar

Related Questions

Have done some research and found some stuff that may be helpful. I would
I have done some research and it really seems that implementing a transaction system
I have done some research on the above and found that I am able
This should be quite easy, and I have done some research on this. I
using Java I have done some research before asking here but I was still
I have done some research and found that it's possible to have a progress
I have done some research and still confused, This is my outcome of that
So I have done some research and found out that MongoDB doesn't do fsync(),
I have done some research, and majority of the examples I have found use
Ok I am still learning this... I have Googled and done some research but

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.