Stack allocated Urho3D::RefCounted variable

Do all RefCounted objects have to be allocated on the heap like this:

SomeObject *foo = new SomeObject(context_);
foo->ReleaseRef(); // <- safe

or can you have them on the stack too:

SomeObject bar(context_)
bar.ReleaseRef(); // <- unsafe ?

it`s OK I guess, only refCount_ is allocated in heap

It’s okay to create Objects on the stack if you could gurantee that neither you nor Urho internal routines create SharedPtr-s for this object.

I think that you could even get away with creating SharedPtrs as long as you manually incremented the reference count first and the SharedPtrs are released before the object goes out of scope, though I’m not certain of this…