CodePudding user response:
Hashmap between the key and the value of a strong reference, will not be garbage collectedIf it is a new map inside elements, is the need to manually release
The map. The clear () just returned the memory to the heap, did not return to the OS, there is a memory object, process memory will always increase
The map=null his hand release
CodePudding user response:
Garbage collection in Java will according to the usage and priority gc will automatically recyclingC + + is to manually release the new things
CodePudding user response:
Hashmap=null just put the map object is empty, the element inside still exist, but lost contact the references, GC is recycling, then the JVM determined according to the situation, not necessarily immediately recyclingCodePudding user response:
Hashmap itself must I don't care, care about containing objects, those objects in the heap memory will automatically be gc collection