KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q23905: Initial Memory Allocation of C Programs

Article: Q23905
Product(s): See article
Version(s): 4.00 5.00 5.10
Operating System(s): MS-DOS
Keyword(s): ENDUSER | DGROUP 64K | mspl13_c
Last Modified: 15-JAN-1990

Question:

I want to make a program "terminate and stay resident." It is a very
short program with only 4K of data and about 2K of code. However, when
I execute the program to make it resident and do a CHKDSK, it seems to
occupy about 70K. Why does it take up so much space?

Response:

The linker normally allocates all of memory to a program. You can use
the /CP switch to adjust the allocation down. If you specify an amount
less than the minimum allocation, the maximum allocation will default
to that minimum, so link with /CP:1.

You can also use the /max <MinimumAllocationInHexParagraphs> option of
the EXEMOD.EXE utility to adjust the maximum allocation of a program.

Microsoft C was not designed for writing memory resident software.
Although it is possible, you also may need to make modifications to
the start-up code. Be cautious about what functions you use and what
DOS functions are called.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.