Can using too many static variables cause a memory leak in Java?

前端 未结 5 1756

If my application has too many static variables or methods, then as per definition they will be stored in heap. Please correct me if I am wrong

1) Will these variab

5条回答
  •  失恋的感觉
    2020-12-08 00:53

    If you have a static hashmap and you add data to it... the data will never disappear and you have a leak - in case you do not need the data anymore. If you need the data, it is not a leak, but a huge pile of memory hanging around.

提交回复
热议问题