ManagedPointer

template <typename ContentClass>
class

Pointer to a heap object, that keeps track of memory references.

The managed pointer is an object designed to live on the stack, but point to memory cobntent that live on the heap. The ManagedPointer keeps track of memory references, such that the it can be shared across multiple objects in your code.

It maintains an internal reference count, to keep track of how many objects holds a reference to itself. If the count reaches zero, then the content is deallocated.

With ManagedPointer you can prevent memory leaks, by ensuring un-references memory gets freed.

Public Functions

mono::ManagedPointer::ManagedPointer()

Create an empty pointer

void mono::ManagedPointer::Surrender()

Give up this ManagedPointers refrences to the content object, by setting its pointer to NULL.

This means that if the Reference count is 1, this pointer is the only existing, and it will not dealloc the content memory upon deletion of the ManagedPointer.

We Reference count is > 1, then other ManagedPointers might dealloc the content memory.