I'm curious about the delete [] operator in C ++. (I am using Visual Studio 2005).
I have an unmanaged DLL called by a managed DLL. When I close this program after performing several tasks during debugging, I get many (thousands?) Memory leaks, mostly 24 bytes - 44 bytes. I suspect this may be due to some unmanaged dll that I have.
In any case, from what I understand, if I have the following code:
char* pointer = new char[500]
delete[] pointer;
Then all the memory for him is freed correctly, am I right?
What happens when I have the following code:
char* pointer = new char[500];
char* pointerIt = pointer;
for (int i = 0; i < 250; i++){
*pointerIt = 0;
pointerIt++;
}
delete[] pointer;
Is the memory pointed to by the pointer deleted correctly? Thus, this means that pointerIt is no longer pointing to actual memory. But this is normal, because I can set both pointers to NULL, right?
, , :
char* pointerFirstPosition = new char[500];
char* pointerIt = pointerFirstPosition;
for (int i = 0; i < 250; i++){
*pointerIt = 0;
pointerIt++;
}
delete[] pointerIt;
, pointerIt pointerIt +500? , pointerFirstPos, FirstPos +500?
?
, .
,