Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda