A computer system has one or more software context that share use of a
memory that is divided into units such as pages. In the preferred
embodiment of the invention, the context are, or include, virtual machines
running on a common hardware platform. The context, as opposed to merely
the addresses or page numbers, of virtual memory pages that accessible to
one or more contexts are examined. If two or more context pages are
identical, then their memory mappings are changed to point to a single,
shared copy of the page in the hardware memory, thereby freeing the memory
space taken up by the redundant copies. The shared copy is ten preferable
marked copy-on-write. Sharing is preferably dynamic, whereby the presence
of redundant copies of pages is preferably determined by hashing page
contents and performing full content comparisons only when two or more
pages hash to the same key.