Patent ID: 7921143

Claim:
A computer storage device having stored computer-executable instructions which, when executed by one or more processors of a computing system, implement a method comprising: executing code corresponding to at least one program; storing objects on a memory heap during execution of the code; storing references to the objects in a process stack during execution of the code; in response to an invocation of a call from managed code to unmanaged code that passes at least one reference to at least one object on the memory heap from the managed code to the unmanaged code to be used by the unmanaged code to manipulate the at least one object on the memory heap, declaring the at least one reference, which is stored on the process stack, as pinned; while the at least one reference is declared as pinned, invoking a garbage collection algorithm which: (1) scans the process stack to identify any references to objects on the memory heap including the at least one pinned reference; (2) traces the heap to identify the objects stored thereon; (3) removes any objects from the memory heap that have been determined to be inaccessible; and (4) relocates any objects within the memory heap that are accessible by one or more of the object references, but are not accessible by any of the at least one pinned reference, while refraining from relocating any objects referenced by at least one pinned reference, including the at least one object referenced by at least one pinned reference.