How is 21MB an issue? Even a single python process with no program loaded almost takes that much memory. Storing 1000000 pairs of 8bytes + 8bytes takes 15MB already. 15MB + 4MB baseline at startup is 19MB, leaving 2MB unaccounted. Most of this is likely HashMap overhead (HashMap's grow before they are fully filled to reduce hash collisions) As for why this memory is still consumed after dropping the HashMap, memory allocators generally don't immediately release freed memory back to the OS in case the program needs more memory in the near future. Some allocators release memory back to the OS once a certain threshold of unallocated memory is reached, while others do so every so often in a background thread.
Thank you for your answer.I understand what you mean
If the memory allocator will not immediately release the operating system in case it is needed in the future, can I understand that if the second or third request is to increase the memory by a small amount on the basis of 21MB, because it is a reused memory? However, the actual situation is not like this. As I have requested multiple times, the memory is increasing