- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue number is DPD200180054.
I will post any updates I receive onthe issueto this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page