O
Osamede Zhang
I just find i can't understand the code like this
int main()
{
int *p=new int;
//do something
delete p;
return 1;
}
I use new operator allocate some memory in the heap,now i don't need
it,but our process also need to be killed.The heap is in our process'
address space,so i think the os should release our heap when it kill
process,isn't it?why i should delete it by myself?
Is there have some problems if i don't delete 'p'?
Thanks for your help.
int main()
{
int *p=new int;
//do something
delete p;
return 1;
}
I use new operator allocate some memory in the heap,now i don't need
it,but our process also need to be killed.The heap is in our process'
address space,so i think the os should release our heap when it kill
process,isn't it?why i should delete it by myself?
Is there have some problems if i don't delete 'p'?
Thanks for your help.