You are currently offline, waiting for your internet to reconnect

How to Avoid "Program Too Large for Memory"

This article was previously published under Q67194
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
When you attempt to run a very large program in MS-DOS, the error"Program Too Large For Memory" may occur. MS-DOS runs in real mode,which does not allow more than 640K of memory for applications. Thisarticle discusses possible methods to circumvent this limitation.These methods include using the OS/2 operating system instead of DOS,direct-access disk file(s) for data storage, ALLOCATABLE arrays, andoverlays.

Using Expanded and Extended Memory with Microsoft FORTRAN

Some DOS applications can use an expanded memory manager (EMM) driverprogram and expanded memory board(s) to access memory beyond the 1 MBlimit of conventional memory. Microsoft FORTRAN, however, does nothave the capability to use expanded memory. It can utilize extendedmemory (above 1 MB), but only when used with the OS/2 operating systemand protected mode libraries. Extended memory is the term used torefer to the memory at physical addresses above 1 MB that can beaccessed by an 80286 or 80386 CPU in protected mode.

Using a Direct Access Disk File to Store Large Amounts of Data

A disk drive can be used to store large amounts of data in a direct-access disk file, thus freeing up the memory that would otherwise beused by the data. By using a direct-access file, records can be readfrom or written to in any order, simulating the use of an array. Ifexpanded or extended memory is available, it can be used for a RAMdrive. By using a RAM drive, I/O access to the data is much fasterthan when using a fixed disk drive.

Using Allocatable Arrays in FORTRAN Version 5.00

An ALLOCATABLE array is an array that is dynamically sized at run timeby using the ALLOCATE statement and the ALLOCATABLE attribute (seepages 21-25 of the "Microsoft FORTRAN Reference" manual). The ALLOCATEstatement (see pages 113-114 of the "Microsoft FORTRAN Reference"manual) establishes the upper and lower bounds of each ARRAY dimensionand reserves sufficient memory. The array can then be DEALLOCATED atrun time by using the DEALLOCATE statement (see page 143 of the"Microsoft FORTRAN Reference" manual) to free memory for use by otherarrays.

For example:
  INTEGER data [ALLOCATABLE] (:,:)  INTEGER error  DATA i, j / 10,50 /   ALLOCATE (data (i,j), STAT=error)  DEALLOCATE (data, STAT=error)				

Using Overlays in FORTRAN Versions 4.00, 4.01, 4.10, and 5.00

Overlays (see pages 366-367 of the "Microsoft FORTRAN Reference"manual for versions 5.00 and pages 258-260 of the "Microsoft FORTRANCodeView and Utilities User's Guide") allow several program modules touse the same memory area. When needed, a module or group of modules isloaded into memory from the disk. Module access time can be shortenedif a RAM drive is used to store the executable. Modules that are to beoverlaid are enclosed in parentheses. CODE (but NEVER DATA) isoverlaid. Note: If the program consists of mostly DATA, then thisprocedure will be of little help.

The following example is for versions 4.00, 4.01, 4.10, and 5.00:
At LINK command line: LINK A (B C) (E F)
Object modules B and C are swapped in and out of the same memory for Object modules E and F. Note: Object modules in parentheses are overlaid together so that they will be loaded into memory at the same time.

The following example is for versions 4.10 and 5.00:
At FL command line: FL MAIN.FOR (OVER1.FOR) (OVER2.FOR)
FORTRAN code modules OVER1 and OVER2 are swapped in and out of the same memory location.
kbinf 4.10 5.00 5.10

Article ID: 67194 - Last Review: 12/01/2003 16:49:14 - Revision: 2.0

  • Microsoft FORTRAN Compiler 4.1
  • Microsoft FORTRAN Compiler 5.0
  • Microsoft FORTRAN Compiler 5.1
  • Microsoft FORTRAN Compiler 4.1
  • Microsoft FORTRAN Compiler 5.0
  • Microsoft FORTRAN Compiler 5.1
  • KB67194
tps://" '="">