Search code examples
c++memsetdelete-operator

Delete calls memset?


Why in call stack after delete this; the following function is being called?

msvcr110d.dll!_VEC_memset(void * dst, int val, int len) 

Please consider that operator delete is not overloaded.


Solution

  • In debug version of the Microsoft C/C++ Runtime library, delete sets the freed memory to 0xDD using memset. That's why you see memset in the callstack. You won't see it in release version.
    Likewise when memory is allocated through new, the newly allocated memory is set to 0xCD.

    You can see some of the details here - https://msdn.microsoft.com/en-us/library/974tc9t1.aspx