Fortran中的大型VIRT内存
问题描述:
虽然使用的实际内存(500 MB)非常适中,但我的Fortran/MPI代码在运行时使用了大量的VIRT内存(〜20G)。Fortran中的大型VIRT内存
如何配置代码以了解哪个部分会产生这个巨大的VIRT内存?
在这个阶段,我甚至很乐意使用暴力方法。 我曾尝试是把睡眠语句中的代码,并记录到“顶”的内存使用情况的二分法在那里大分配的尝试针点。 然而,这不起作用的睡眠调用使内存的使用情况为0。有没有办法冻结代码,同时保持当前的内存使用情况? PS:我已经尝试了VALGRIND,但代码太大了,VALGRIND从来没有完成过。 VALGRIND是否有替代品可以“轻松”使用?
谢谢
山姆
答
对此的解决方案是这一修改(获得VIRT内存)子程序从跟踪内存使用Fortran 90的
subroutine system_mem_usage(valueRSS)
use ifport !if on intel compiler
implicit none
integer, intent(out) :: valueRSS
character(len=200):: filename=' '
character(len=80) :: line
character(len=8) :: pid_char=' '
integer :: pid
logical :: ifxst
valueRSS=-1 ! return negative number if not found
!--- get process ID
pid=getpid()
write(pid_char,'(I8)') pid
filename='/proc/'//trim(adjustl(pid_char))//'/status'
!--- read system file
inquire (file=filename,exist=ifxst)
if (.not.ifxst) then
write (*,*) 'system file does not exist'
return
endif
open(unit=100, file=filename, action='read')
do
read (100,'(a)',end=120) line
if (line(1:7).eq.'VmSize:') then
read (line(8:),*) valueRSS
exit
endif
enddo
120 continue
close(100)
return
end subroutine system_mem_usage
你尝试[这]( https://*.com/questions/22028571/track-memory-usage-in-fortran-90)? – A4L
它有帮助。谢谢 ! – sponce