Windows array allocation problem



I'm getting an "insufficient virtual memory" error when trying to allocate an array to a size which is about 385 MB less than the amount of available virtual memory. I'm using the Intel Visual Fortran v. 9.1 compiler, with the compiler and program running under Windows XP.

The allocation statement is

ALLOCATE(A(N), STAT = IStat)

where A is a KIND = 4 complex array. The operation fails, with STAT = 41 (insufficient virtual memory) with N somewhere between 214,358,000 and 214,358,881. These correspond to allocated array sizes of 1,714,864,000 and 1,714,871,048 bytes respectively. (SIZEOF(A) shows the correct size after allocation even when the allocation returns STAT = 41.) The former succeeds, the latter fails. In both cases a call to Windows API function GlobalMemoryStatus or GlobalMemoryStatusEx immediately before the ALLOCATE statement returns a value of available virtual memory of 2,118,221,824 bytes. So I'm getting an "insufficient virtual memory" failure when trying to allocate the array to a size which is 384.665 MB less than the amount of reported available virtual memory. The operation succeeds when the allocated array size is 384.672 MB less than the amount of reported virtual memory, or less.

My questions are:

1. Why can't I allocate an array to a size much closer to the amount of available virtual memory? I realize, of course, that I have to allow for other memory use by the program in deciding the maximum I can safely allocate, but that's not the issue here.
2. If I won't be able to allocate nearly all the available virtual memory, how can I determine in advance how much I *can* safely allocate?

The Intel documentation says in numerous places that virtual memory problems should be addressed by adjusting the virtual memory setting in the Windows Control Panel. I'm a bit confused by this, because I'm under the impression that every 32 bit Windows program has an allocation of 2 GB of virtual memory. Isn't this the pool of memory the array is being allocated within? At any rate, changes to the Control Panel page file setting have no apparent effect on the problem.

Any insight would be greatly appreciated!

Thanks,
Roy Lewallen
.



Relevant Pages

  • Re: Mergesort Vs Quicksort
    ... given as variable-length records packed end-to-end in one array, ... If your dataset is large enough that you can't allocate two full ... oodles of extra virtual memory you can allocate virtually for free, ... also allocating each CONS cell on the heap, ...
    (comp.programming)
  • Re: Windows array allocation problem
    ... allocate an array to a size which is about 385 MB less than the amount of available virtual memory. ... In both cases a call to Windows API function GlobalMemoryStatus or GlobalMemoryStatusEx immediately before the ALLOCATE statement returns a value of available virtual memory of 2,118,221,824 bytes. ... So I'm getting an "insufficient virtual memory" failure when trying to allocate the array to a size which is 384.665 MB less than the amount of reported available virtual memory. ...
    (comp.lang.fortran)
  • Re: Windows array allocation problem
    ... allocate an array to a size which is about 385 MB less than the amount of available virtual memory. ... In both cases a call to Windows API function GlobalMemoryStatus or GlobalMemoryStatusEx immediately before the ALLOCATE statement returns a value of available virtual memory of 2,118,221,824 bytes. ... So I'm getting an "insufficient virtual memory" failure when trying to allocate the array to a size which is 384.665 MB less than the amount of reported available virtual memory. ...
    (comp.lang.fortran)
  • Re: memory leak
    ... MSFT have already said that they will fix this problem, ... What is your definition of "video RAM"? ... You could try to allocate and have it throw if you're out of virtual memory. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: how much swap size did you take?
    ... virtual memory is used to contain executing processes. ... I created lazy allocate ... ... to allocate a corresponding page on disk. ... This "duplicate" allocation scenario requires that amount ...
    (alt.os.linux.redhat)