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

memory leakage or something else?

henrylou
Beginner
537 Views
I used quite a lot allocatable arrays in my code. My problem is as follow:

I know for Win2K Professional version, the largest memory can be used for each application is about 1.75G (about 1792M?). Before I want to allocate a large 2-dim array, I checked the memory left. Then I calculated the largest dimensions for that array. I can guarantee my calculation is correct and it should allow me to allocate the array. However, I still have the problem to allocate the space.

The run-time error is 41, which indicates there is no enough virtual memory. However, from information from the code, I have so much memory to use for the array.

Is that due to memory leakage? If so, it should still be OK since I just checked the memory before allocating. Or maybe each allocate command requires some extra memory? I am confused. Any help would be appreciated.

SOme additional info:

OS: Win2K Prof. SP3
Compiler: Comapq Visual Fortran 6.6
It is a console application.
0 Kudos
6 Replies
Steven_L_Intel1
Employee
537 Views
How do you "check the memory left"? Keep in mind that allocation requires that there be a contiguous, unallocated segment of virtual memory available. Yes, each allocate has a small amount of overhead for tracking data, but this is generally not a problem.

How close can you get to your computed maximum?

Steve
0 Kudos
henrylou
Beginner
537 Views
I used the function call "getmemstat" for available memory virtual before allocation. For a 32-bit application, the usable virtual memory is about 1.75G (actually for a small testing program, it is about 1.8G I tested). Before anything, the available virtual memory I got is about 2G, I can easily set the difference (d) as about 0.25G, which is not usable. So before I allocate, I call "getmemstat" to get current available virtual memory, then substract d from it. I use this substracted number as the base to compute the maximum.

However sometimes I cannot use as much as 1.7G virtual memory for my application.

> How do you "check the memory left"? Keep in mind that
> allocation requires that there be a contiguous,
> unallocated segment of virtual memory available.
> Yes, each allocate has a small amount of overhead
> for tracking data, but this is generally not a
> problem.
>
> How close can you get to your computed maximum?
>
> Steve

0 Kudos
Steven_L_Intel1
Employee
537 Views
The error is coming from the Win32 API routine we use to allocate the memory. (Depending on the allocation size, we may use a Win32 call or a C library call.)

Steve
0 Kudos
henrylou
Beginner
537 Views
Thanks for all the information.

Will that be fixed in near future such as a patch?

> The error is coming from the Win32 API routine we use
> to allocate the memory. (Depending on the allocation
> size, we may use a Win32 call or a C library call.)
>
> Steve

0 Kudos
james1
Beginner
537 Views
The "fix" would be to move to an operating system that supports more than 2Gb of user addressable virtual memory space. Either one of the 32 bit Windows line that supports the /3Gb switch or a 64 bit OS.

James
0 Kudos
Steven_L_Intel1
Employee
537 Views
When I said "the error" I meant the failure status - I did not mean to imply that there is a bug in the software. CVF just returns what it Windows tells it in this case.

Steve
0 Kudos
Reply