Add memory_object::reference_count() method

This adds a reference_count() method to the memory_object
class which returns its current reference count.