Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

Is there any founction to calculate the maximum memory/bits could be allocated?

Zhanghong_T_
Novice
528 Views
Hi all,
I have to solve large problem which could lead to out-of-memory in IA-32 system. I want to know the maximum memory could be allocated to avoid trouble in execution. Except the code 'ALLOCATE(A(N),STAT=ERR)', is there any function to calculate themaximun memory could be allocated?
Thanks,
Zhanghong Tang
0 Kudos
3 Replies
Les_Neilson
Valued Contributor II
528 Views

From another post(see Memory Allocation)Steve Lionel said :

"32-bit Windows has a hard limit of 2GB. The practical limit is somewhat less. It isn't a compiler limitation. The amount of RAM you have does not directly affect this (except that too little RAM will mean you can allocate even less.)"

My emphasis.

However there is a way to get memory and pagefile information :

Code:

subroutine GetMemStats
  use kernel32
  implicit none

  real*8 dbAvailPhys
  real*8 dbAvailPageFile

  real*4, parameter :: dbDivide = 1024;

  integer*4 dwAvailPhys
  integer*4 dwAvailPageFile

  type(T_MEMORYSTATUS) lpMstMemStat
  type(T_MEMORYSTATUSEX) lpMstMemStatEx

  ! Call windows API to get memory status
  call GlobalMemoryStatus(lpMstMemStat)

  ! Copy to local variables
  dwAvailPhys = lpMstMemStat.dwAvailPhys
  dwAvailPageFile = lpMstMemStat.dwAvailPageFile

  ! To return data in Mb, divide by (1024 * 1024) by Bit shift 2^10 and / 1024
  dbAvailPhys = dble(RShift(dwAvailPhys, 10) / dbDivide)
  dbAvailPageFile = dble(RShift(dwAvailPageFile, 10) / dbDivide)

  write(*,*) 'Available Physical = ',dbAvailPhys
  write(*,*) 'Available PageFile = ',dbAvailPageFile 

end subroutine GetMemStats



Hope this helps

Les

0 Kudos
Steven_L_Intel1
Employee
528 Views
Just keep in mind that this is still a theoretical maximum. If the free address space is fragmented, you may not be able to allocate one large contiguous chunk.
0 Kudos
Zhanghong_T_
Novice
528 Views
Hi,
Thank both of you very much!
Zhanghong Tang
0 Kudos
Reply