- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have found that a constantly deallocated memory at the end of the subroutine (or even the program). I am wondering if I made anything wrong here. I suppose that all allocated memories must be deallocated at the end. But the diagnostic tool tells me 'Allocations (diff)' is still +5 at the end. The example code is attached.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not seeing a problem here, and your description seems strange.
The memory you allocate with ALLOCATE is completely deallocated by the DEALLOCATE. There is additional memory that has been allocated for the I/O operations - those are not explicitly deallocated by the program but go away when the process exits.
In the screenshot below, I did a snapshot before and after the ALLOCATE and before and after the DEALLOCATE.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Try: (i) containing the subroutine within the main program, (ii) using a module. For example, in the first case,
program leak_test
implicit none
double precision, allocatable :: mat(:,:)
integer :: i
allocate (mat(100, 100))
do i = 1, 100000
call sub_calc(mat)
if (mod(i, 1000) == 0) print *, "iteration: ", i
end do
deallocate(mat)
contains
subroutine sub_calc(a)
implicit none
double precision :: a(1000, 1000)
a(1,1) = a(1,1) + 1.0d0
end subroutine sub_calc
end program leak_test
Then,
$ ifx --version
ifx (IFX) 2025.3.3 20260319
Copyright (C) 1985-2026 Intel Corporation. All rights reserved.
$ ifx -mtune=generic -std18 -WB -warn all -check all -o testcase-0222-ifx.exe testcase-0222.f90
$ testcase-0222-ifx.exe
iteration: 1000
iteration: 2000
...
iteration: 98000
iteration: 99000
iteration: 100000
Regards,
Jorge D'Elia
@mchoi wrote:Hello,
I have found that a constantly deallocated memory at the end of the subroutine (or even the program). I am wondering if I made anything wrong here. I suppose that all allocated memories must be deallocated at the end. But the diagnostic tool tells me 'Allocations (diff)' is still +5 at the end. The example code is attached.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Try: (i) using a module; (ii) containing the subroutine within the main program. For example, in the second case:
program leak_test
implicit none
double precision, allocatable :: mat(:,:)
integer :: i
allocate (mat(100, 100))
do i = 1, 100000
call sub_calc(mat)
if (mod(i, 1000) == 0) print *, "iteration: ", i
end do
deallocate(mat)
contains
subroutine sub_calc(a)
implicit none
double precision :: a(1000, 1000)
a(1,1) = a(1,1) + 1.0d0
end subroutine sub_calc
end program leak_test
$ ifx --version
ifx (IFX) 2025.3.3 20260319
Copyright (C) 1985-2026 Intel Corporation. All rights reserved.
$ ifx -mtune=generic -std18 -WB -warn all -check all -o testcase-0222-ifx.exe testcase-0222.f90
$ testcase-0222-ifx.exe
iteration: 1000
iteration: 2000
...
iteration: 99000
iteration: 100000
Regards.
Jorge.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not seeing a problem here, and your description seems strange.
The memory you allocate with ALLOCATE is completely deallocated by the DEALLOCATE. There is additional memory that has been allocated for the I/O operations - those are not explicitly deallocated by the program but go away when the process exits.
In the screenshot below, I did a snapshot before and after the ALLOCATE and before and after the DEALLOCATE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. Yes, here, after removing the PRINT, I have no more additional memory allocation. It is now +0 in total.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page