Andreas,
Thanks for the patch and the example. You're right, we should avoid
copying the ref count of the old datatype. The new datatype need a
ref count set to one when it get out of the dup function. I will
commit the patch to the trunk.
Thanks,
george.
On Nov 12, 2006, at 9:00 PM, Andreas Schäfer wrote:
Hi,
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.
Cheers!
-Andreas
diff -ru openmpi-1.1.1/ompi/datatype/dt_create_dup.c
openmpi-1.1.1-fixed/ompi/datatype/dt_create_dup.c
--- openmpi-1.1.1/ompi/datatype/dt_create_dup.c 2006-06-14
21:56:41.000000000 +0200
+++ openmpi-1.1.1-fixed/ompi/datatype/dt_create_dup.c 2006-11-13
00:35:03.000000000 +0100
@@ -33,6 +33,7 @@
int32_t old_index = pdt->d_f_to_c_index;
memcpy( pdt, oldType, sizeof(ompi_datatype_t) );
+ ((opal_object_t *)pdt)->obj_reference_count = 1;
pdt->desc.desc = temp;
pdt->flags &= (~DT_FLAG_PREDEFINED);
/* ompi_ddt_create() creates a new f_to_c index that was saved
<memleak_fileio.cc>
_______________________________________________
devel mailing list
de...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/devel