"Insufficient EMS to Load Overlays" at Run Time in 7.00, 7.10 (64876)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1

This article was previously published under Q64876

SUMMARY

The run-time error message "Insufficient EMS to load overlays" 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 "Microsoft Basic 7.0: Language Reference" 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 "Insufficient EMS to load overlays" 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 "Insufficient EMS to load overlays" 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 "best guess" 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).

REFERENCES

For more information about how to use link overlays in Basic 7.00 and 7.10, search in this Knowledge Base for a separate article with the following words:

How and link and overlays and expanded and memory and Basic

See also the section "Linking with Overlays" on Pages 612-614 in the "Microsoft Basic 7.0: Programmer's Guide" for versions 7.00 and 7.10.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB64876