one of our projects recently exposed severe memory leakage when using
ROMIO to write a complex derived datatype (a struct made of other
structs) to a file. From our code we distilled the attached short
program to reproduce the leak.

After some Valgrind sessions, it appears as if the memcpy in
ompi_ddt_duplicate() is a bit overhasty, as it does copy the old
type's reference counter, too.

I don't know if this is the right way to fix it, but if I apply the
patch below to ompi the leak is fixed.