S
Sean
Here is a confusion about free() and delete. Someone told me that the memory
chunk allocated in c++ will be automatically released back to system for
future use. I haven't been convinced.
In C,
main()
{
int* p
p = malloc(100*sizeof(int));
return 0; //A
}
(1) After my program returns, will this chuck of heap be released back to
system?
(2) if I change line A to exit(1), will this chuck of heap be released back
to system?
In C++
int main()
{
int* p = new int[100];
return 0; //B
}
(3) someone told me that this chuck of heap has been released back to system
after the program exits, EVEN THOUGH there is no delete operation. Is it
TRUE or not?
(4) If it's true: if I change line B to exit(1), will the memory be
released?
Thank you
chunk allocated in c++ will be automatically released back to system for
future use. I haven't been convinced.
In C,
main()
{
int* p
p = malloc(100*sizeof(int));
return 0; //A
}
(1) After my program returns, will this chuck of heap be released back to
system?
(2) if I change line A to exit(1), will this chuck of heap be released back
to system?
In C++
int main()
{
int* p = new int[100];
return 0; //B
}
(3) someone told me that this chuck of heap has been released back to system
after the program exits, EVEN THOUGH there is no delete operation. Is it
TRUE or not?
(4) If it's true: if I change line B to exit(1), will the memory be
released?
Thank you