When I allocate and free memory and afterwards I allocate memory that is max the size as the previously freed part.
May the 2nd allocation be faster than the first?
Maybe because it already knows a memory region that is free? Or because this part of the heap is still assigned to the process? Are there other possible advantages?
Or does it generally make no difference?
Edit: As asked in the comments:
- I am especially interested in gcc and MSVC.
- My assumption was that the memory was not "redeemed" by the OS before.
As there is a lot going about specific details about implementation, I'd like to make it more clear, that this is a hypothetical question. I don't intend to abuse this, but I just want to know IF this may occur and what the reasons for the hypothetical speedup might be.