1 (edited by Boris_MV 2015-04-25 00:49:05)

Topic: Allocation would exceed memory limit PROBLEM

Hi there,

I get following error message:

                                   Operating system error: Not enough space
                                       Allocation would exceed memory limit

when I want to allocate in RAM complex double precision matrix size of 11,000 or larger. Such matrix takes approximately 2*8*(11000)^2/1024^3 = 1.8GB of RAM and I have 98 GB RAM available. In the performance monitor I can see that I am not taking  more than 6GB our of the 98GB RAM at any time.

Please advise.
Thanks.

Re: Allocation would exceed memory limit PROBLEM

My advice would be to avoid such large arrays if possible.

However, if you really need a 11000 X 11000 array you could try just creating it in static memory.

Something like,

DOUBLE PRECISION, SAVE, DIMENSION(11000,11000) :: A

or the old-fashioned F77 way

DOUBLE PRECISION A(11000,11000)
SAVE A

--
David

Re: Allocation would exceed memory limit PROBLEM

Boris,

There are two things to check when allocating such large amounts of RAM.  First, make sure your project is configured as a 64-bit executable.  A 32-bit executable probably won't be able to allocate a full 2GB, even on 64-bit Windows, due to Windows limits.

Second, under compiler flags under both "Fortran" and "Linker," add the following flag:

-mcmodel=medium

The above flag allows large allocations in your code.  It should allow for 2GB of static allocation and basically unlimited dynamic allocation. 

Make sure, though, that you are using Fortran's ALLOCATE calls.  The static 2GB limit is a hard limit that cannot be increased (at least in this version of our included compiler).

Jeff Armstrong
Approximatrix, LLC

Re: Allocation would exceed memory limit PROBLEM

Thank you both. Let me see what can I do with your advises and I'll report back how it went.
b

5 (edited by Boris_MV 2015-04-30 19:44:49)

Re: Allocation would exceed memory limit PROBLEM

Compiling my code as 64-bit project helped, and I was able to process matrices up to size 14,000 (2.92GB).

Using flags “-mcmodel=medium” in the two edit boxes (FORTRAN COMPILER and LINKER) didn’t help to go beyond 14,000 size (I nee to process matrices of around 22,0000 in size).

I still get the same error for matrices larger than 14,000. All the matrices I use vary in size over the iterations in a for-loop, so all of them are ALLOCATABLE.

If you have more advices, I would greatly appreciate. I’ll keep on looking for the problem and will post my findings here. Thanks once again!

Re: Allocation would exceed memory limit PROBLEM

I'll  try -mcmodel=large.

Re: Allocation would exceed memory limit PROBLEM

It didn't work with:
                                    -mcmodel=large

Re: Allocation would exceed memory limit PROBLEM

Here is one interesting information.

- The ALLOCATION of the large (18k by 18k) matrix went well.
- However, during the SETUP (CALCULATION) of the matrix elements of the large matrix the execution stopped with the error message:
=================================================
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
=================================================
No other output info.

Re: Allocation would exceed memory limit PROBLEM

Boris,

The flags:

-mcmodel=medium

should definitely provide enough allocation space on the heap.  I would suggest that you try immediately initializing all memory associated with an array in an attempt to force the memory manager to access the entire block.  Something simple like:

ALLOCATE(bigdata(21000:21000))
bigdata = 0.0

The above might help the situation.

Do you explicitly deallocate the arrays when you've finished with them?

Jeff Armstrong
Approximatrix, LLC

Re: Allocation would exceed memory limit PROBLEM

Thanks Jeff!  I'll try that and will post results here.

At the end of each iteration (simply, it's one for-loop) I use DEALLOCATE explicitly for all ALLOCATABLE matrices/vectors.  In this (test) case I was running just one iteration and the program breaks down after the big matrix is successfully allocated and during setup (calculation) of the matrix elements.  The program never reached the part where LAPACK calculates eigenvalues of this big matrix.

In the meantime, here is some more error info that I got when running the program using command line.
==================================================
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
job aborted:
[ranks] message
[0] process exited without calling finalize
[1-31] terminated
---- error analysis ----
[0] on MSW10
target.exe ended prematurely and may have crashed. exit code 3.
---- error analysis ----
===================================================

Re: Allocation would exceed memory limit PROBLEM

Jeff,

I've tried :
ALLOCATE(Hamiltonian(18000:18000))
Hamiltonian= CMPLX(0.0, 0.0)

And the program successfully passes the line where I am enforcing all the elements to (complex) zero. It was very quick, just a minute or two.
Now, there is slow part where several complicated functions are setting up the actual values of "Hamiltonian." This takes five hours or longer. This is the place where the program breaks down for large matrices.
Will keep you posted.

Re: Allocation would exceed memory limit PROBLEM

The same thing happened. The program reported the same error during the setup of the matrix elements.

Re: Allocation would exceed memory limit PROBLEM

I think I'll just run debugger.... for the first time.

Re: Allocation would exceed memory limit PROBLEM

It was a bug with the length of one vector. The program now runs fine with very large matrices. And its very fast.
Thanks!!!

Re: Allocation would exceed memory limit PROBLEM

Good to hear that everything is working!

Jeff Armstrong
Approximatrix, LLC