Chapter 12. Memory ManagementWhile memory management may not rate as the most interesting subject for the majority of developers, it is important that your application use memory carefully. This is especially the case with Windows CE since devices have limited amounts of memory available to applications. Your application should allocate memory in the most appropriate way (that is from a heap, as static variables, or local variables on a stack) and ensure that memory is freed when finished with. In Windows CE, applications need also to respond to low-memory situations by carefully checking that memory allocations succeed and also by freeing up memory that is not currently essential. By doing this, an application becomes a good citizen in the Windows CE world. Windows CE provides similar memory architecture to Windows NT/98/2000 it supports a virtual address space in which pages are mapped to physical memory. However, there are significant differences, such as the lack of a page file and the address space allocated to applications. These differences are outlined in this chapter. Just as with Windows NT/98/2000, an application can work directly with the virtual address space for memory allocations. However, the vast majority of applications can use higher-level memory allocation techniques, such as the stack and the heap.
|