Perhaps because it makes sense to optimize distribution through release, because many applications allocate without release, but never the other way around. I myself saw a similar model in an application that mixes calls with malloc and free (as opposed to distributing and releasing all at once).
I never wrote a heap allocator, so I don't know if there is a deeper technical reason. When exempting from unauthorized access, it is necessary to find and combine adjacent free blocks. Thus, the work is simply fundamentally different.
90 seconds for 1 million small free() sounds are pretty slow. I never programmed Windows, so I canβt say that itβs not normal, but the system should be able to do much better.
The solution to your problem may simply be to skip the release of objects before the program exits. You can try to get a custom allocator from std::allocator< unsigned int > , which makes deallocate no-op.
source share