The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Rogare on April 05, 2011, 11:34:25 AM

Title: Memory allocation problem
Post by: Rogare on April 05, 2011, 11:34:25 AM
Hi,

I'm trying to allocate memory during run-time (21h/48h), but I keep getting error 8, saying largest available block is only 7 paragraphs (I need several blocks of 8 paragraphs).
Any idea what causes this limitation?

Thanks.
Title: Re: Memory allocation problem
Post by: dedndave on April 05, 2011, 12:44:06 PM
it has been a while since i did this in 16-bit   :P
i seem to recall that you had to free heap space beyond the exe bss segment before allocating
Title: Re: Memory allocation problem
Post by: FORTRANS on April 05, 2011, 01:04:50 PM
Hi,

   When running DOS programs, if you have not changed any
default behavior, the program is allocated all available memory
at program load.  Therefore, there will be no conventional memory
left to allocate.

   To free up memory, you either release memory when your
program starts using Int 21H, Fn 49H.  Or you link your program
with the /CPARMAXALLOC: option ( /CP: ).  /CP:1 is supposed
to only allocate to your program what it should need to load and
run.  (If you specify less memory than your program needs, LINK
is supposed to allocate what your program needs.  And most of
the time...)  If you know how much your program requires at
load, you can specify the number as /CP:##.  (Where ## is a
number specifying how much memory you need.)

HTH,

Steve N.
Title: Re: Memory allocation problem
Post by: Rogare on April 05, 2011, 07:30:43 PM
Yep. Thanks!