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

memory de-fragmentation

jaeger0
Beginner
619 Views
In my project I need a 3D-array with require a large amount of memory.
Sometimes memory allocation fails, even if there should be enough memory available.
So I did a memory test.
I tested the maximum allocatable size for a single array (with the command ALLOCATE), and the size of many smaller allocatable arrays. So the maximum allocatable single array was only 700 MB, where the total size using multiple arrays was 2000 MB's.
So my question is, is there any possibility to tell the system to de-fragment system memory in order to make a larger memory-block accessible, instead of many small memory fragments ?

0 Kudos
8 Replies
TimP
Honored Contributor III
619 Views
This would be highly dependent on which OS you use.
0 Kudos
jaeger0
Beginner
619 Views
I use Windows XP/windows 7
0 Kudos
ZlamalJakub
New Contributor III
619 Views
I think it is not possible (other programs can fragment memory and there is no way to force them to change used memory position (i.e. address of its variables)).

Use smaller arrays and pointers to work with them.

Jakub
0 Kudos
Les_Neilson
Valued Contributor II
619 Views
If you allocate many arrays yourself then if possible you should allocate the largest arrays first. But if you do many allocate/deallocate calls then memory is bound to get fragmented and the memory manager (garbage collector) may not be quite up-to-date with your process (so I have been told)

What is your definition of "large amount of memory" ? How big are your arrays ?

Les
0 Kudos
jimdempseyatthecove
Honored Contributor III
619 Views
Jaeger0,

Can you upgrade your system to a 64-bit operating system?

If you are unable to do this then consider writing a 2D array of 1D arrays

Jim
0 Kudos
jimdempseyatthecove
Honored Contributor III
619 Views
By the way, yourWindows 7 serial number should be good for both x32 and x64 versions of Windosw 7.

Jim
0 Kudos
jaeger0
Beginner
619 Views
I have a 64bit version, but my programm is compiled as a 32 bit version, since one library I use is still in 32 bit, so I guess I have no other option to split up my array.
0 Kudos
jimdempseyatthecove
Honored Contributor III
619 Views
What portion of your code uses the 32-bit library?

If this 32-bit library does not use the large 3D array, or can be written to use smaller pieces of the 3D array, then consider writing your application in two pieces. Or properly phrased as in two processes. One process can be in 64-bit, the other in 32 bit. The two processes can share data using a memory mapped file(s) for data sharing. And there are various inter-process communication methods (Events etc...).

Jim Dempsey
0 Kudos
Reply