Patent ID: 8769229

Claim:
At a computer system including one or more processors and system memory, the computer system also including a managed execution environment, a method for pinning a managed memory buffer, the method comprising: an act of instantiating a wrapper object on behalf of a native routine executing in a native execution environment, the wrapper object configured to regulate management of a memory buffer in a managed execution environment; an act of passing a reference to the wrapper object from the managed execution environment to the native routine; an act of receiving a first call from the native routine to the wrapper object, the first call generated by the native routine prior to executing an asynchronous operation; responsive to receiving the first call: an act of pinning the memory buffer, thereby preventing a memory manager from moving the memory buffer within a managed memory heap during execution of the asynchronous operation; and an act of passing a memory pointer to the native routine through the wrapper object, the memory pointer identifying the memory buffer for use by the native routine during execution of the asynchronous operation; subsequent to receiving the first call, an act of receiving a second call from the native routine to the wrapper object, the second call generated by the native routine after executing the asynchronous operation; and responsive to receiving the second call, an act of unpinning the memory buffer, thereby allowing the memory manager to move the memory buffer within the managed memory heap.