- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank both of you very much!
Zhanghong Tang

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page