When combining new[]
with delete
instead of delete[]
, what really happens? I tried the following code and found there is no memory leak, so why does delete
on a new[]
returned pointer not cause a leak?
How does the compiler know the number of bytes to be freed?
int main() {
constexpr int size = 102400;
while (1) {
char* buffer = new char[size]{};
delete buffer;
}
return 0;
}