Patent ID: 7620766

Claim:
A method for sharing memory in a computer system that includes a hardware memory divided into a plurality of memory units and at least one context that has an address space having a plurality of context page numbers that are mappable to the memory units, the method comprising: selecting a candidate memory unit, the candidate memory unit being one of the memory units; calculating a current hash value that is a function of contents of the candidate memory unit; accessing a data structure to determine whether the data structure includes a matching entry having a hash value matching the current hash value, the data structure containing previously calculated hash values and corresponding memory units from which the hash values were calculated; when the data structure includes the matching entry: mapping context page numbers corresponding to the candidate memory unit and the matching memory unit to a single memory unit; and write-protecting the single memory unit; and when the data structure does not include the matching entry: creating a new entry for the candidate memory unit in the data structure and keeping a current write-protect status of the candidate memory unit until another memory unit is identified having a matching entry.