The official document says, "The tracemalloc module is a debug tool to trace memory blocks allocated by Python."
Python uses memory management as Arena and stores through pools and blocks.
However, even if python actually free the block, python do not return the memory directly to the os. All blocks in the pool must be free to return the memory.
So is it possible that tracemalloc only tracks Python's free, but doesn't know that memory is returned to the actual os, and that Python is actually using more memory than it is tracked?
It only tells you the memory that Python has currently allocated to store variables.
Python requests memory from the OS in arenas that are typically 256k, much bigger than the variables themselves.
When a block (part of a pool) is no longer needed by Python, but other blocks in that pool are still in use, Python cannot release the pool to the OS. It can't release the pool until all pools in the arena are free. It is rare for that to happen, because there is almost always something in an arena that is still needed. An exception might be a function that creates large temporary variables and then discards them all without making any other use of that arena.
More information here: