[comp.os.msdos.programmer] Help! Microsoft C program size problem!

tdg1465@hertz.njit.edu (tod gordon cccc) (05/31/91)

We are working on a program that requires about 300-310K to start,
before heap allocations begin. I notice that Microsoft C 6.0, which
we now use (with their linker), allocates 64k above what is quoted
in the .EXE file header. Reasonably, it should use this for something
like heap space, but at least 47K of it never gets used - the heap
allocations begin above this. If I compile with Borland C++, this
kind of waste doesn't happen, but we can't use Borland's compiler
for development now.

This 64K addition is mentioned in the linker documentation as being
added by the startup module as a minimum (see /CP option). We need
all the heap space we can get, and can't afford this kind of waste.
Is there a way around this?

----------
Tod Gordon (tdg1465@hertz.njit.edu)

reaper@wixer.helps.cs.utexas.edu (Keath Milligan) (06/01/91)

Concerning your size problem:  Even if your program is large model, LINK will
by default allocate space for a near heap.  This near heap will be 64k minus
the total size of all your near-data-segment items.  This is probably where 
that wasted 47k is coming from.

In addition to that, LINK will also (by default) construct the .EXE so that it
will allocate all available main memory when it runs.

Try using  "/CP:1"  this will cause LINK to not reserve space for a near heap
and construct the .EXE so that it will only allocate as much memory as it
needs when it runs.