[comp.windows.ms.programmer] GetFreeSpace in Enhanced Mode

robertt@hp-vcd.HP.COM (Bob Taylor) (05/01/91)

A quick question for anybody that knows:

Is there anyway to find out how much real memory (RAM) is available in
enhanced mode vs. how big the swapfile is?  I'm trying to allocate really
big blocks of memory (> 2 meg), but it needs to be in RAM, not on disk.
If I use GetFreeSpace to determine what I can allocate, I can't tell the
difference between a system with 16M RAM/2M Swapfile and 2M RAM/16M Swapfile.
For the first, I'd allocate a much bigger block of memory than for the
second.

Essentially, I'm looking for the following two pieces of information:
1) Amount of physical RAM installed
2) Size of the current Swapfile.

Windows obviously knows this info - does anybody know how I can get it?

thanks -

bob taylor
HP Vancouver

Norbert_Unterberg@p4.f36.n245.z2.fidonet.org (Norbert Unterberg) (05/03/91)

 > Essentially, I'm looking for the following two pieces of information:
 > 1) Amount of physical RAM installed
 > 2) Size of the current Swapfile.
 >
 > Windows obviously knows this info - does anybody know how I can get it?

There is a DPMI call to obtain that piece of information. DPMI call 0500h with 
ES:DI pointing to a 30h byte buffer returns the `Free Memory Information':

Offset      Description
 00h        Largest available free block in bytes
 04h        Maximum unlocked page allocation
 08h        Maximum locked page allocation
 0Ch        Linear address space size in pages
 10h        Total number of unlocked pages
 14h        Number of free pages
 18h        Total number of physical pages           <----- !!!
 1Ch        Free linear address space in pages
 20h        Size of paging file/partition in pages   <----- !!!
 24h-2Fh    Reserved

The size of one page in bytes can be determined by function 0604h. It returns 
the page size in bytes in BX:CX.
To call a DPMI function, invoce an interrupt 31h. Carry clear id call was 
successful.

The complete DPMI 0.9 specification is available free(!) at Intel Literature 
JP26, Santa Clara.