PRODUCT : Borland C++ NUMBER : 735 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 1/2 TITLE : Determining Program Size /********************************************************************** The size of a program cannot be determined statically because the the stack and near heap are sized dynamically at run time. The load size specified in the EXE header is incorrect for this reason. The only way to accurately determine the program image size is to check it at run time. This program will get the current size of the program image in memory. This size will change dynamically as the program acquires memory from and releases memory to DOS. This in formation is stored in the Memory Control Block (MCB). The MCB begins one paragraph (16 bytes) before the Program Segment Prefix (PSP). The current program size is stored at offset 0x3 from the beginning of the MCB. Offset 0x3 represents the size in paragraphs therefore it must be multiplied by 16 to obtain the size in bytes. WRITTEN BY Jerry Shockley 9/19/91 **********************************************************************/ #include unsigned _stklen = 63000u; //This size can be changed to see the size // size change. void main() { unsigned far *size; size = MK_FP( _psp - 1, 0x03 ); printf("\nSize of program in memory = %l0u", (unsigned long) (*size) * 16 ); } PRODUCT : Borland C++ NUMBER : 735 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 2/2 TITLE : Determining Program Size DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.