A memory leak means the loss of a pointer value to allocated memory. Once the value has been lost, it is no longer possible to release the memory.
The lifetime of a static pointer is the the entire execution of the process. Thus the pointer value was never lost, because it was always stored, and at no point of the program is there a situation where the pointer couldn't be freed.
Valgrind documentation classifies such memory as:
"Still reachable". This covers cases 1 and 2 (for the BBB blocks) above. A start-pointer or chain of start-pointers to the block is found. Since the block is still pointed at, the programmer could, at least in principle, have freed it before program exit. "Still reachable" blocks are very common and arguably not a problem. So, by default, Memcheck won't report such blocks individually.
Is there some kind of "automatic free"
Not in the sense of a call to free
, but once a program stops, it no longer exists and its allocations are of no concern.