Skip to content

Commit 903fca7

Browse files
authored
FabArray::copyTo(FAB): Fix a memory leak (#5246)
1 parent 2628014 commit 903fca7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Src/Base/AMReX_FabArrayCommI.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ FabArray<FAB>::copyTo (FAB& dest, int scomp, int dcomp, int ncomp, int nghost) c
768768
T* const p0 = dest.dataPtr(dcomp);
769769
T* pb = p0;
770770
#ifdef AMREX_USE_GPU
771-
if (dest.arena()->isDevice()) {
771+
if (dest.arena()->isDevice() && !ParallelDescriptor::UseGpuAwareMpi()) {
772772
pb = (T*)The_Pinned_Arena()->alloc(sizeof(T)*count);
773773
Gpu::dtoh_memcpy_async(pb, p0, sizeof(T)*count);
774774
Gpu::streamSynchronize();
@@ -780,6 +780,7 @@ FabArray<FAB>::copyTo (FAB& dest, int scomp, int dcomp, int ncomp, int nghost) c
780780
if (pb != p0) {
781781
Gpu::htod_memcpy_async(p0, pb, sizeof(T)*count);
782782
Gpu::streamSynchronize();
783+
The_Pinned_Arena()->free(pb);
783784
}
784785
#endif
785786
}

0 commit comments

Comments
 (0)