Monitoring How an Application Uses RAM

Windows CE provides two tools to monitor how much memory your application is currently using: a map file and the Remote Memory Viewer. The two tools are quite different. A map file is a data file produced by the compile and link process and the Remote Memory Viewer is a utility included in the Windows CE integrated development environment (IDE). The Remote Memory Viewer requires that your desktop computer be connected to a remote device to get information about your application's memory use. However, you can get valuable information from a map file without being connected to a remote device. In this section, we briefly discuss making and using a map file, followed by a detailed discussion of Remote Access Viewer.

A memory map file is very helpful to a programmer because it shows how much memory is used in each static section of your application. When you build your application, if you set the map link option, the linker makes a memory map data file and writes it to your hard drive. The length of each static section is provided at the top of the file. In addition to showing the static section lengths, a map file also shows how much data is in the read-only section, .rdata. The R/W data section is composed of two subsections: .data, which contains all initialized global data, and .bss, which contains uninitialized data. R/W data is initialized to zero by the loader. Note the section number, which is typically two for R/W. Then, look in the symbols area of the map file to see what data is in this section and how much space each item uses. For example, to calculate the total memory that is taken up by R/W, add the amount needed by .data and .bss and round up to the next multiple of the page size.