Memory accounting

QNX SDP8.0System ArchitectureDeveloperUser

Accounting for the memory used by your system and processes can be useful, especially when debugging. This section covers examples of how to read memory-related files and calculate reserved memory.

The actual calculations you perform will depend on your needs, and, due to the varying nature of different types of mapping, may be complex. The process counters discussed in this section provide a general value that represents reserved memory. To get an accurate value, you need to perform more complicated calculations using the raw information found in the memory manager.

The QNX OS provides several counters that provide statistics about system and process memory usage:
  • The /proc/vm/stats file allows you to display system-wide statistics. For example:
    cat /proc/vm/stats
    For details, go to System counters.
  • For process totals, display the contents of /proc/pid/vmstat, where pid is the process ID. For example:
    cat /proc/pid/vmstat
    For details, go to Process counters.
  • The /proc/pid/mappings file has detailed mapping information for each page in your process. For example:
    cat /proc/pid/mappings
    For more information, go to The mappings file.

Alternatively, you can use the code snippets provided in Using C library APIs to calculate memory reservations to determine how much private and shared memory your process is using.

Terminology

The following terminology is used for this discussion of memory accounting:

Anonymous
Used to refer to memory that is not associated with an explicit object. Anonymous memory can come from anywhere in RAM and is zero-initialized when allocated.
Domain
A collection of contiguous ranges of physical memory that serve a particular type of allocation (single page, multi-page, kernel).
Map
A structure that is used to construct the page table entry for each page in the address space.
Page

A fixed-length contiguous block of memory. The QNX OS process manager allocates memory in pages (typically 4 KB each).

Region
A region is a sub-range of a process's address space. It is the result of a mmap() call. The pages in a region all share the same backing object, protection bits, and flags.
Page updated: