Microsoft KB Archive/64876

= &quot;Insufficient EMS to Load Overlays&quot; at Run Time in 7.00, 7.10 =

Article ID: 64876

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q64876



SUMMARY
The run-time error message &quot;Insufficient EMS to load overlays&quot; occurs (if it is going to occur at all) when the first overlaid module is called. This error is documented on Page 656 of the &quot;Microsoft Basic 7.0: Language Reference&quot; manual for Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10. The article below explains in more detail why you might get this error condition.

This information applies to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS when using linked overlays.



MORE INFORMATION
The &quot;Insufficient EMS to load overlays&quot; error message is not random. If you run a program on a particular machine and the error does not occur, the error will never occur for that program unless that machine's expanded memory configuration is changed. Common ways of changing the expanded memory configuration include the following: setting up a larger RAM drive in expanded memory; or moving the program to another machine with a different amount of free expanded memory.

If a given program produces an &quot;Insufficient EMS to load overlays&quot; error on a given machine, the error will always occur for that program as long as the machine's expanded memory configuration and usage stay the same.

When a Basic program calls the first overlaid module, the program must estimate the space in expanded memory necessary to load all overlays at once. This estimate is based only on the following:
 * 1) The number of overlays
 * 2) The size of the largest overlay
 * 3) The fact that each overlay has less than 64K of code (otherwise, it would not be able to use expanded memory)

The overlay manager in Basic 7.00 and 7.10 requests expanded memory in 16K pages (blocks). The overlay manager knows the size of only the largest overlay and must make a &quot;best guess&quot; at the size of the smaller overlays. When the overlay manager estimates how many 16K pages are necessary to hold all overlays at once in expanded memory, the estimate could be over or under the actual number of pages needed. If your overlays are all between 16K and 64K in size (according to the LINK .MAP file), and if the estimated or actual size of all overlays together exceeds the available expanded memory, the following initialization error occurs when the first overlay is called at run-time:

Insufficient EMS to load overlays

NOTE: You will never see this error if all your overlays are smaller than 16K each.

If you want to force loading overlays from disk, thus avoiding the possibility of this overlay-initialization error in expanded memory, you must link with the stub file NOEMS.OBJ (with no parentheses around NOEMS.OBJ on the LINK command line). Alternatively, you can try reconfiguring expanded memory so more of it is available for Basic overlays. Another alternative is to make overlays similar in size.

To find out the size of each overlay, you must look at the .MAP file generated by the linker (LINK.EXE).

