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/24935

From BetaArchive Wiki

How Min/Max Memory Allocations Effect Program Loading


5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg ---------------------------------------------------------------------- The information in this article applies to: - The C Run-time (CRT) included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 ---------------------------------------------------------------------- SUMMARY ======= Changing the minimum or maximum allocation values in an executable file affects the method in which MS-DOS allocates memory for the application. MORE INFORMATION ================ MS-DOS dynamically allocates memory for an application when it is first loaded. Initially, MS-DOS attempts to allocate FFFFh paragraphs of memory. This attempt always fails and the memory manager returns the size of the largest free block of memory. If this block is smaller than the minimum allocation and the load size, a "no memory" error occurs and MS-DOS cannot load the application. If the largest free block is larger than the sum of the maximum allocation and the load size, MS-DOS allocates the amount specified by the sum of the maximum allocation and the load size. Otherwise, MS-DOS allocates the largest free block for the application. Usually, the default maximum allocation is sufficient for a given application. However, there are cases in which changing the maximum allocation provides better functionality. One such case is a menu program that spawns other programs. Because the menu program remains in memory, this maximum allocation should be set as low as possible to maximize the memory available to the spawned applications. In the small memory model, the C startup code returns to MS-DOS all memory allocated for the application except for a 64K block reserved for the default data segment. If an application uses only 4K in its default data segment, it can return the remaining memory to MS-DOS as well. To change the maximum allocation to 4K, specify the /CP:1 option on the Microsoft LINK command line or use the EXEHDR or EXEMOD utilities to modify an existing executable file. For more information, see the LINK, EXEHDR, or EXEMOD documentation. Additional reference words: kbinf 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00 KBCategory: kbprg KBSubcategory: CRTIss

Keywords : kb16bitonly
Issue type :
Technology : kbVCsearch kbAudDeveloper kbCRT

Last Reviewed: May 5, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.