Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Memory release problem

wdliu
Principiante
402 Visualizações
Hi,
We are running the latest Intel Compiler (v. 8.1.2380.2003) and encountering a memory release problem. It would be greatly appreciated if anyone can shed some light on this problem.

Bellow is the code. Test was done on a Dell box with 2GB physical memory.

Following an allocation of a small space (~500MB), a second call was trying to allocate more space (~1.8GB). It failed out-of-space, because the first allocated space was not released properly still reserved. The code, however, runs perfect under some other values of n and m.

Thanks in advance

David
--------------------------------------------------------

program main
implicit none
integer :: n, m, more
!
! n is the number of integer_pointers which will be allocated
! m is the total allocation size (each pointer is dimensioned m/n)
!
! For m = 200000000
! n = 1000 is OK
! n = 2000 does not release memory
!
! For n = 2000
! m = 10000000 does not release memory
! m = 50000000 does not release memory
! m = 100000000 does not release memory
! m = 200000000 does not release memory
! m = 300000000 is OK
! m = 400000000 is OK
!
n = 1000 ! number of integer_pointers
m = 130000000 ! total allocation size
call alloc(n,m)
call more_allocs() ! allocates 1.8GB
!
end program main

subroutine alloc(n,m)
implicit none
integer, intent(in) :: n, m
!
type integer_pointer
integer, pointer :: i(:) => null()
end type integer_pointer
type (integer_pointer), dimension(:),allocatable :: a
!
integer :: i, nsize, ierr
!
! If nsize > 130000, this works OK
!
nsize = m/n
allocate(a(n),stat = ierr)
do i = 1, n
allocate(a(i)%i(nsize),stat = ierr)
if(ierr /= 0)return
a(i)%i = 1
end do
do i = n, 1, -1
if(associated(a(i)%i))deallocate(a(i)%i)
nullify(a(i)%i)
end do
deallocate(a)

end subroutine

subroutine more_allocs()
implicit none
!
type integer_pointer
integer, pointer :: i(:) => null()
end type integer_pointer
type (integer_pointer), dimension(:),allocatable :: a
!
integer :: i, n, nsize, ierr
!
nsize = 200000
n = 2250
allocate(a(n),stat = ierr)
do i = 1, n
allocate(a(i)%i(nsize),stat = ierr)
if(ierr /= 0)then
write(*,*)"Out of space"
return
endif
a(i)%i = 1
end do
do i = n, 1, -1
deallocate(a(i)%i)
nullify(a(i)%i)
end do
deallocate(a)
!
end subroutine more_allocs

Message Edited by wdliu on 11-10-2004 09:29 AM

0 Kudos
0 Respostas
Responder