Skip to content

Commit d94e8c9

Browse files
committed
ompi/runtime: release F90 types in ompi_mpi_finalize()
F90 types cannot be freed by the enduser as specified by the standard. but since they are ompi_datatype_dup'ed from predefined datatypes, they have to be explicitly free'd at finalize time in order to avoid a memory leak. Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 45732fd commit d94e8c9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ompi/runtime/ompi_mpi_finalize.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ int ompi_mpi_finalize(void)
105105
ompi_proc_t** procs;
106106
size_t nprocs;
107107
volatile bool active;
108+
uint32_t key;
109+
ompi_datatype_t * datatype;
108110
OPAL_TIMING_DECLARE(tm);
109111
OPAL_TIMING_INIT_EXT(&tm, OPAL_TIMING_GET_TIME_OF_DAY);
110112

@@ -297,14 +299,16 @@ int ompi_mpi_finalize(void)
297299
}
298300
OBJ_DESTRUCT(&ompi_registered_datareps);
299301

300-
/* Remove all F90 types from the hash tables. As the OBJ_DESTRUCT will
301-
* call a special destructor able to release predefined types, we can
302-
* simply call the OBJ_DESTRUCT on the hash table and all memory will
303-
* be correctly released.
304-
*/
305-
OBJ_DESTRUCT( &ompi_mpi_f90_integer_hashtable );
306-
OBJ_DESTRUCT( &ompi_mpi_f90_real_hashtable );
307-
OBJ_DESTRUCT( &ompi_mpi_f90_complex_hashtable );
302+
/* Remove all F90 types from the hash tables */
303+
OPAL_HASH_TABLE_FOREACH(key, uint32, datatype, &ompi_mpi_f90_integer_hashtable)
304+
OBJ_RELEASE(datatype);
305+
OBJ_DESTRUCT(&ompi_mpi_f90_integer_hashtable);
306+
OPAL_HASH_TABLE_FOREACH(key, uint32, datatype, &ompi_mpi_f90_real_hashtable)
307+
OBJ_RELEASE(datatype);
308+
OBJ_DESTRUCT(&ompi_mpi_f90_real_hashtable);
309+
OPAL_HASH_TABLE_FOREACH(key, uint32, datatype, &ompi_mpi_f90_complex_hashtable)
310+
OBJ_RELEASE(datatype);
311+
OBJ_DESTRUCT(&ompi_mpi_f90_complex_hashtable);
308312

309313
/* Free communication objects */
310314

0 commit comments

Comments
 (0)