Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/102633

From BetaArchive Wiki
Knowledge Base


Controlling Overlay Memory Usage in Visual Basic for MS-DOS

PSS ID Number: 102633

Article Last Modified on 1/8/2003



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS 1.0



This article was previously published under Q102633

SUMMARY

You can set the amount of conventional memory that the overlay manager reserves for loading overlays by using either of the following methods:

  • Set the environment variable OVERLAY_HEAP to the desired heap size, in kilobytes, before you run your program.
  • Link your program with a modified version of the MOVEINIT.C module, which is supplied with Microsoft C/C++ version 7.0, as described in detail below. This technique requires Microsoft C/C++ version 7.0.


MORE INFORMATION

The file MOVEINIT.C contains two alternative versions of the _moveinit overlay initialization procedure. The first decides what heap size to request based on the number and size of the overlays and available memory. The second looks for environment variables to determine memory usage. This article describes how to modify the version of _moveinit that does not look for environment variables.

Note that environment variable names that MOVEINIT.C uses are different from the names that Visual Basic for MS-DOS usually uses. MOVEINIT.C uses MOVE_HEAP, MOVE_XMS, and MOVE_EMS whereas Visual Basuc for MS-DOS usually uses OVERLAY_HEAP, OVERLAY_XMS, and OVERLAY_EMS.

The _moveinit procedure, located in MOVEINIT.C at line 17, sets the overlay heap size with the following call to _movesetheap, at line 126:

   movesetheap ($$COVL, cparaLarge, cparaMax);
                

This requests the heap size to be the sum of the sizes of the three largest overlays. The first argument is the number of overlays. The second argument is the minimum heap size, which is the size of the largest overlay. Do not modify the first or second arguments.

The third parameter is the requested heap size, specified in 16-byte paragraphs. You can modify the third argument. However, do not use a value smaller than the variable cparaLarge. For example, the following statement requests the minimum heap size possible:

   _movesetheap ($$COVL, cparaLarge, cparaLarge);
                

In another example, the following statement requests a heap size that is the size of the largest overlay plus 16000 bytes:

   _movesetheap ($$COVL, cparaLarge, cparaLarge + 1000);
                

You can also set the amount of extended memory (XMS) and expanded memory (EMS) to be used for caching overlays by modifying the following statement located at line 168:

   _movesetcache (ckbXms, ckbEms);
                

This statement allocates enough XMS or EMS memory to cache all overlays. The first argument to _movesetcache requests XMS memory; the second requests EMS memory, in kilobytes. You can modify both arguments, but do not use values larger than ckbXms and ckbEms, respectively.

The following example commands show how to compile and link the NOTEPAD sample program with the C/C++ version 7.0 MOVEINIT.C program. Locate the files MOVEINIT.C and MOVEAPI.H in the current directory. Do not place MOVEINIT.OBJ in an overlay.

cl -c -Gs moveinit.c
bc /o /d /e /x notepad;
bc /o /d /e /x cmndlg;
bc /o /d /e /x cmndlgf;
bc /o /d /e /x help;
bc /o /d /e /x helpf;
bc /o /d /e /x helputil;
link notepad moveinit (cmndlg) (cmndlgf) (help) (helpf) (helputil);


For more information on _movesetheap and _movesetcache, see the file MOVEAPI.TXT supplied with C/C++ version 7.0. You can find the files MOVEINIT.C, MOVEAPI.H, and MOVEAPI.TXT in the C/C++ version 7.0 subdirectory SOURCE\MOVE.


Additional query words: VBmsdos 1.00

Keywords: KB102633
Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3