Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
java - Garbage collection on the hashmap

I just want to find out how the GC reclaims memory for instances stored in the hashmap.

I am using a hashmap for my application, but because of the complexity of the code and dependencies, I am trying to find out a way to fix without tweaking a lot of code if possible as the best case.

I have a hashmap which stores instances, but it keeps growing by creating duplicate objects without removing it before creation. It is a bug, but this hashmap is referenced by other components. When the GC runs, this hashmap is not a candidate for being discarded, but it is referenced by other components used for running the application. But some of the objects(references) inside the hashmap are not needed, but it is not discarded. I tried to use WeakHashMap, but it isn't still garbage-collected.

Does it mean that even though the object inside the hashmap is not referenced by other instances, if the hashmap is still referenced by other instance, the instance inside the map is not a candidate for GC?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!