I'm trying to understand your simplified and hence inaccurate account
OK, what I really was about is a bit OT, but your post led me to
reminisce.
Years ago, it was very easy to make memory leaks but very hard to find
them. Nowadays it's still easy to make them, but there are automated
tools that keep track, so really, there's not good excuse for a
professional level program to have them.
I remember years ago creating a macro, actually a fairly simple one, in
one rather large and complicated C program of mine, that caught and
counted calls to alloc and dealloc and reported to me the net count when
I closed the program. It didn't tell me why the count wasn't zero, but
just having that count info helped *a lot*...