Be careful when checking the return value. The above documentation seems to imply that it will represent the number of references or 0. But I have found the value will be less than 0 under certain circumstances. This is important to know if you are using a loop that your condition for exiting is <=0 and not == 0 which would cause an endless loop.