Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Possible Memory Leak in ifort 2016

Zuodong_Y_
Novice
575 Views

It's related to allocating an allocatable component of a user-defined type array with source or mold option, I'm not sure whether this is a wrong way of using mold/source or is a known issue and will be fixed in 2017 version. Anyway, here is the example:

program main
	implicit none
	type t_test
		real(8), allocatable :: T(:) 
	end type
	real(8) :: B(2)
	type(t_test) :: A(1)

	do
		allocate(A(1)%T,mold=B)
		!allocate(A(1)%T,source=B)
	enddo

end program

and memory leaks!

if change "A(1)" to a scale "A", then allocate statement will raise a "allocatable array is already allocated" error. I'm not sure whether this error is normal or mold/source should reallocate automatically if shape doesn't match?

compiled with Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.3.210 Build 20160415

0 Kudos
1 Solution
Steven_L_Intel1
Employee
575 Views

I expect this to be fixed in Update 2 to Parallel Studio XE 2017.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
575 Views

Thanks - the subsequent ALLOCATEs should cause a run-time error. The standard says, "An allocatable variable with [allocated] status may be referenced, defined, or deallocated; allocating it causes an error condition in the ALLOCATE statement." I'm not sure why that's not happening here and will send this on to the developers. Issue ID is DPD200414580.

From what I can see, if SOURCE= or MOLD= is used, no check for "already allocated" is done, which is incorrect.

0 Kudos
Steven_L_Intel1
Employee
576 Views

I expect this to be fixed in Update 2 to Parallel Studio XE 2017.

0 Kudos
Reply