- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,It seems thatcall move_alloc(from, to)does not deallocate "to" if it is already allocated. It is a nice way to make memory leaks. I don't know what the Fortran standard has to say about it, but I don't see any reason why it should leak memory.I also realized that when "to" goes out of scope, is is not deallocated.Franois
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Do you have any test code to support your comments? The following code works just as expected (and the amount of memory used is always the same):
[fortran]implicit none
integer :: i
real, allocatable :: a(:), b(:)
do i = 1, 10
print '(("ALLOCATED(", A, ")=", L1))', 'a', ALLOCATED(a), 'b', ALLOCATED(B)
allocate (a(100), b(100))
a = 1
b = 2
call MOVE_ALLOC(a, b)
print '(("ALLOCATED(", A, ")=", L1))', 'a', ALLOCATED(a), 'b', ALLOCATED(B)
print '("b(1)=", G0)', b(1)
call reset(b)
read *
enddo
contains
subroutine reset(x)
real, allocatable, intent(OUT) :: x(:)
end subroutine
end[/fortran] The MOVE_ALLOC intrinsic is for ALLOCATABLE variables only ---which, by definition, DO NOT leak memory---. The deallocation of the "to" argument should occur, simply because it has INTENT(OUT); after that, the array descriptor from "from" is moved to "to", which means that on return the actual argument "to" is allocated and has the contents of the actual argument "from"... In simple terms, all MOVE_ALLOC does is changing the name of a variable.
The Fortran standard, does not specify implementation details, so I suppose the deallocation of an ALLOCATABLE variable that goes out of scope could be done asynchronously without any problem.
If you're using some memory debugging tool (e.g., valgrind), and your program does not rely heavily on pointers, just ignore the (false positive) messages regarding memory leaks.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
We need to be able to reproduce the problem in order to investigate it though.
Could youshare the original program in a privateresponse orthough premier support? Only Intel employees will be able to see a response that has been marked private.
Thanks,
Annalee
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The issue number is DPD200180054.
I will post any updates I receive onthe issueto this thread.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
A fix has been found for this issue, we are planning to include it in the next major release which is scheduled for later this year.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고