This is just a toy example where I'm allocating a pointer to a type, and then immediately nullifying it. When calling this in a loop the memory used steadily increases until the program eventually crashes with "forrtl: severe (41): insufficient virtual memory". Using the latest version of the compiler (18.104.22.168, 32bit) on Windows 7. Am I doing something crazy here? I tend to avoid pointers, but I have a situation where I need to use them (linked lists). My application is leaking memory, and I've reduced the problem down to this. My understanding is that this code is OK, but maybe I'm totally confused. Any help is appreciated.
module test_module implicit none type,public :: blah character(len=10000) :: a = '' integer,dimension(100,100) :: b = 0 end type blah contains subroutine memory_leak() implicit none type(blah),pointer :: p write(*,*) 'blah' allocate(p) ! ! do stuff with p... ! nullify(p) end subroutine memory_leak end module test_module program test use test_module integer :: i i=0 do i=i+1 write(*,*) i call memory_leak() end do end program test