I believe that it completely depends on the operating system, when you call free (), it can return this memory right away or not care and just mark this memory segment as a possible acquisition at a later date (probably the same). I know the memory (if significant) appears in the task manager immediately after free () on the windows.
Keep in mind that the memory we are talking about here is virtual . Thus, the operating system can tell you everything it wants, and most likely is not an accurate representation of the physical state of the machine.
Think about how you will manage memory allocation, if you were writing an OS, you probably wouldn't want to do anything hasty that could waste resources. We are talking about 128 bytes here, do you want to spend the processing time of important processing, processing it alone? This can be the cause of this behavior or not, at least believable. Do it in a loop and then free () in another loop or just allocate large chunks of memory, see what happens, experiment.
user2180519
source share