J
Jianwei Sun
I have a question, it may sound stupid. In c#/Java , when you create an object
on the heap and don't reference anymore, the memory will be cleared out when
garbage collection walk thourough the memory region.
But in C++, if I do:
Object* pObj=new Object();
delete pObj;
Then will the memory be cleared right away? Or when we do delete pObj, it
actually *just* break the reference to the object in the heap, so it will
be ready to be cleared. Thanks.
If I do this:
Object* pObj=new Object();
Object** ppObj=new Object*;
*ppObj=pObj;
delete ppObj;
The object will still be availble after delete, right?
on the heap and don't reference anymore, the memory will be cleared out when
garbage collection walk thourough the memory region.
But in C++, if I do:
Object* pObj=new Object();
delete pObj;
Then will the memory be cleared right away? Or when we do delete pObj, it
actually *just* break the reference to the object in the heap, so it will
be ready to be cleared. Thanks.
If I do this:
Object* pObj=new Object();
Object** ppObj=new Object*;
*ppObj=pObj;
delete ppObj;
The object will still be availble after delete, right?