To clarify: in C++, Panda makes liberal use of automatic reference counting. This should be documented on this page, though that looks pretty incomplete.
A short summary: a large number of classes in Panda inherit from a base class called ReferenceCount. These objects must be treated a little differently from conventional objects: when allocated, their reference count is initially zero. You are expected to immediately increment the reference count, and when the reference count is later decremented back to zero, the object will be automatically deleted.
You are not expected to increment and decrement the reference counts explicitly, however. This is handled automatically by Panda’s “magic pointer” class, a template class called PointerTo, which is abbreviated with the macro PT. In general, PT(MyClass) can be treated the same as (MyClass *), and should be read “pointer to MyClass”. PT(MyClass) is special, though, because when you assign a pointer value into it, it will increment the pointer’s reference count; and when you assign a new value (or destruct the PT(MyClass) itself), it will decrement the pointer’s reference count.
Thus, in Panda, you don’t actually need to do anything special to manage reference counts other than to be careful to use PT(MyClass) instead of MyClass * to store pointers to things that inherit from ReferenceCount.
There are a few other fiddly rules. You can’t ever explicitly delete a ReferenceCount object, because then you’ll get a double-delete when the reference count tries to delete it too. You normally don’t create automatic or local ReferenceCount objects, instead you always use the new operator to allocate one from the heap (though there’s a way to create an automatic instance if you need to, but that’s more advanced).
When we pass a ReferenceCount object into a method, we normally accept it with a MyClass * pointer on the parameter list, because in that case we don’t really need the overhead of PT(MyClass), since the reference count is still held by the caller. When we return a ReferenceCount object from a method, we either return a PT(MyClass) if the method is not retaining ownership of the object internally, or we return a MyClass * if it is (in which case, again, it doesn’t need the overhead of PT(MyClass)). In general, though, if you have any doubt, you should use a PT(MyClass) to store a pointer to a ReferenceCount object.
David