TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mario Semo
from: Peter Fitzsimmons
date: 1996-06-11 12:51:36
subject: Toolkit 1.3 from Devcon

MS> Under OS/2 WARP GA you CAN:

 MS>  DosAllocMem(1byte,READ/WRITE)
 MS>  DosSetMem(64K,committed) -> OK
 MS>  DosSetMem(64K+1byte committed) -> ERROR

 MS>  so, it appears as 64K IS allocated whatever you say 
 MS> refering to ancient OS/2 toolkits prior to DevCon8. 

The memory is not "backed by physical storage" until the
DosSetMem(64k,...).  Until then it is just (wasted) address space.

Actually,  even that's not quite true under Warp (or even later 2.11
fixpaks).  Even a committed page will not be backed by physical ram until
it is referenced for the first time.   Additionally, If a page contains all
zeros,  it is "packed",  and the ram is discarded.  For example,
this program will not commit much ram at all:


 #define INCL_NOPMAPI
 #define INCL_DOS
 #include 
 #include 
 #include 

 int main(int argc, char **argv)
 {
     ULONG ul;
     APIRET rc;
     PBYTE mem;
     int i;

     ul = atol(argv[1]);
     printf("Allocating %d bytes\n", ul);

     rc = DosAllocMem((PPVOID)&mem, ul,  PAG_COMMIT | PAG_WRITE | PAG_READ);
     if(rc){
         printf("sys%04u: dosallocmem()\n", rc);
         return 1;
     }
     printf("Memory not really commited yet;  Press enter\n");
     getchar();

     printf("Touching %d pages:\n", ul/0x1000);
     for(i=0; i * Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 517 628 713/888 800/1
@PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.