An important approach for software dependability is the use of diversity to detect and/or tolerate errors.We develop and evaluate an approach for automated program diversity called Diverse Partial Memory Replication (DPMR), aimed at detecting memory safety errors.DPMR is an automatic compiler transformation that replicates some subset of an executable's data memory and applies one or more diversity transformations to the replica.DPMR can detect any kind of memory safety error in any part of a program's data memory.Moreover, DPMR is novel because it uses partial replication within a single address space, replicating (and comparing) only a subset of a program's memory.We propose and evaluate two strategies for handling pointers stored in memory, a key challenge to DPMR. We also perform a detailed study of the diversity mechanisms and state comparison policies in DPMR (a first of its kind for such diversity approaches), which is valuable for exploiting the high flexibility of DPMR.Finally, we explore the use of Data Structure Analysis to eliminate nearly all restrictions on input programs that would otherwise be necessary.