Patent ID: 8677076

Claim:
A method, comprising: performing, by one or more computers: associating a portion of a shared memory with a reference tracking data structure comprising an owner field and an array of two or more atomically addressable entries, wherein each of the entries comprises a per-thread reference counter and a per-thread counter lock, and wherein at most a single thread can own the reference tracking data structure at any given time; assigning each individual thread of one or more of a plurality of threads to a different respective one of the two or more entries of the array, wherein each of the one or more of the plurality of threads is assigned to a different entry in the array such that at most a single thread is assigned to any given one of the entries, wherein the per-thread reference counter of each entry indicates a current number of references to the portion of the shared memory by the thread assigned to the entry, and wherein the per-thread counter lock of each entry indicates whether the thread assigned to the entry is currently updating the per-thread reference counter of the entry; one of the plurality of threads determining whether the current number of references to the portion of the shared memory is zero or non-zero, wherein said determining comprises: the one of the plurality of threads writing a particular value in the owner field to acquire ownership of the reference tracking data structure; and the one of the plurality of threads examining one or more of the entries of the array; and the one of the plurality of threads returning a value indicating whether the current number of references to the portion of the shared memory is zero or is non-zero.