[alt.msdos.programmer] How much memory is left during execution?

ralphc@tekcae.CAX.TEK.COM (Ralph Carpenter) (10/07/89)

Can anyone on the net give me any leads on how to find out how much
usable memory is left when a program is executing?

Most of our code is completely MicroSoft Fortran, some is mixed
Fortran and M/S C, and some is all M/S C.  We currently don't know
how close to the 640K limit a program is until we try it, and then
just that it has enough memory or it doesn't.

Thanks in advance.

Ralph Carpenter
ralphc@tekcae.CAX.TEK.COM

Wes@cup.portal.com (Wes H Cowley) (10/08/89)

This isn't considered "well-behaved", especially if you're going to ever move
the code to a multitasking environment, but you can use Int 21h function 48h
to request more memory than the system has.  One of the return values will
tell you how much is available.

	Call with: AX == 48h
		   BX == FFFFh
	Return:
		   AX == 08h (Insufficient memory)
		   BX == Size of largest memory block available.

This won't give you total memory available if memory is fragmented, but in
most cases will tell you most of the available memory.