Implementation of ObjectSpace.count_objects