Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda