Figure 3   Memory Map of MemDemo

Address Page Status Size Access rights Comments
0000 0000 Reserved 65,536    
0001 0000 Reserved 4,096   Start of EXE
0001 1000 Image 2,048 Execute, Read-only Code
0001 1800 Reserved 1,024    
0001 1C00 Image 1,024 Execute, Read-only  
0001 2000 Reserved 2,048    
0001 2800 Image 8,192 Execute, Read-only  
0001 4800 Reserved 2,048    
0001 5000 Image 1,024 Execute, Read-only  
0001 5400 Reserved 11,264    
0001 8000 Image 3,072 Read-only Read-only static data
0001 8C00 Reserved 1,024    
0001 9000 Image 1,024 Read-write Read-write static data
0001 9400 Reserved 1,024    
0001 9800 Image 7,168 Read-write  
0001 B400 Reserved 7,168    
0001 D000 Image 2,048 Read-only Resource data segment
0001 D800 Reserved 2,048    
0001 E000 Free 8,192    
0002 0000 Reserved 54,272   Stack
0002 D400 Private 7,168 Read-write  
0002 F000 Free 4,096   Guard page(s)
0003 0000 Private 1,024 Read-write Local Heap
0003 0400 Reserved 392,192    
0009 0000 Free 30,408,704   Free
01D9 0000 Reserved 1,024   COMMCTRL image
01D9 0400 Image 237,568 Execute, Read-only  
01DC A400 Image 2,048 Read-write  
01DC AC00 Reserved 7,168    
01DC C800 Image 7,168 Read-only  
01DC E400 Reserved 13,312    
01DD 1800 Free 2,091,008   Free
01FD 0000 Reserved 1,024   COREDLL image
01FD 0400 Image 119,808 Execute, Read-only  
01FE D800 Image 1,024 Read-write  
01FE DC00 Reserved 8,192    
01FE FC00 Image 1,024 Read-only  
01FF 0000 Reserved 5,120    
01FF 1400 Free 60,416    


Figure 4   Partial Visual C++ Map File


 memtest
 
 Timestamp is 34ce4088 (Tue Jan 27 12:16:08 1998)
 
 Preferred load address is 00010000
 
 Start         Length     Name                   Class
 0001:00000000 00006100H .text                   CODE
 0002:00000000 00000310H .rdata                  DATA
 0002:00000310 00000014H .xdata                  DATA
 0002:00000324 00000028H .idata$2                DATA
 0002:0000034c 00000014H .idata$3                DATA
 0002:00000360 000000f4H .idata$4                DATA
 0002:00000454 000003eeH .idata$6                DATA
 0002:00000842 00000000H .edata                  DATA
 0003:00000000 000000f4H .idata$5                DATA
 0003:000000f4 00000004H .CRT$XCA                DATA
 0003:000000f8 00000004H .CRT$XCZ                DATA
 0003:000000fc 00000004H .CRT$XIA                DATA
 0003:00000100 00000004H .CRT$XIZ                DATA
 0003:00000104 00000004H .CRT$XPA                DATA
 0003:00000108 00000004H .CRT$XPZ                DATA
 0003:0000010c 00000004H .CRT$XTA                DATA
 0003:00000110 00000004H .CRT$XTZ                DATA
 0003:00000114 000011e8H .data                   DATA
 0003:000012fc 0000108cH .bss                    DATA
 0004:00000000 000003e8H .pdata                  DATA
 0005:00000000 000000f0H .rsrc$01                DATA
 0005:000000f0 00000334H .rsrc$02                DATA
 
  Address         Publics by Value              Rva+Base     Lib:Object
 
 0001:00000000       _WinMain                   00011000 f   memtest.obj
 0001:0000007c       _InitApp                   0001107c f   memtest.obj
 0001:000000d4       _InitInstance              000110d4 f   memtest.obj
 0001:00000164       _TermInstance              00011164 f   memtest.obj
 0001:00000248       _MainWndProc               00011248 f   memtest.obj
 0001:000002b0       _GetFixedEquiv             000112b0 f   memtest.obj
 0001:00000350       _DoCreateMain              00011350 f   memtest.obj.
 
 .
 .
 .

Figure 5   Opening a Memory-Mapped File


 HANDLE hFile, hFileMap;
 PBYTE pFileMem;
 TCHAR szFileName[MAX_PATH];
 
 // Get the file name
 
 hFile = CreateFileForMapping(szFileName, GENERIC_READ, FILE_SHARE_READ, 
                              NULL, OPEN_EXISTING,    
		FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, 0); 
     
 if (hFile != INVALID_HANDLE_VALUE) {
 
 hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, 0);
     if (hFileMap) {
         pFileMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);
         if (pFileMem) {
             //
             // Use the data in the file
             //
 
             // Start cleanup by unmapping view
             UnmapViewOfFile (pFileMem);
         }
         CloseHandle (hFileMap);
     } 
     CloseHandle (hFile);
 } 

Figure 8   Handheld PC Low Memory Thresholds

Event Free memory
1,024 page size
Free memory
4,096 page size
Comments
Enter limited memory state 128KB 160KB Send WM_HIBERNATE messages and reclaim free stack space as needed
Enter low memory state 64KB 96KB Limit virtual allocs to 16KB. Low memory dialog displayed.
Enter critical memory state 16KB 48KB Limit virtual allocs to 8KB.