Chapter 7: Memory Management
Overview
If you have an overriding concern when you're writing a Microsoft Windows CE program, it should be dealing with memory. A Windows CE machine might have only 4 MB of RAM. This is a tiny amount compared with that of a standard personal computer, which typically needs 128 MB or more. In fact, memory on a Windows CE machine is so scarce that it's sometimes necessary to write programs that conserve memory even to the point of sacrificing the overall performance of the application.Fortunately, although the amount of memory is small in a Windows CE system, the functions available for managing that memory are fairly complete. Windows CE implements almost the full Win32 memory management API available under Microsoft Windows XP and Microsoft Windows Me. Windows CE supports virtual memory allocations, local and separate heaps, and even memory-mapped files.Like Windows XP, Windows CE supports a 32-bit flat address space with memory protection between applications. But because Windows CE was designed for different environments, its underlying memory architecture is different from that for Windows XP. These differences can affect how you design a Windows CE application. In this chapter, I'll describe the basic memory architecture of Windows CE. I'll also cover the different types of memory allocation available to Windows CE programs and how to use each memory type to minimize your application's memory footprint.