Forums » C++ Framework » Understading memory collector: release + new »
| Jaime Barrachina | Understading memory collector: release + new | ||||
|---|---|---|---|---|---|
|
Added by Jaime Barrachina over 1 year ago
Hello, class A : public CCNode
{ class B : public CCNode
{ void B::func()
{ What happens when I call The A object is added to the B object, but not created using the release / retain / autorelease mechanism. Thank you for your help! |
||||
| Zhe Wang | RE: Understading memory collector: release + new | ||||
|
Added by Zhe Wang over 1 year ago
A a = new A; // a.m_uRefCount = 1 this->addChild(a,0,0); // b holds a, so a.m_uRefCount = 2 a->release(); // paring to new A So next time when you B->removeAllChildren(true), a.m_uRefCount will reduce to 0 and be released, you don't need to call an extra delete. Enjoy Coding, Enjoy Life. |
||||
| Jaime Barrachina | RE: Understading memory collector: release + new | ||||
|
Added by Jaime Barrachina over 1 year ago
Thank you very much. That helped a lot. |
(1-2/2)
