Direct allocation from typed memory

Directly allocating memory from a memory pool that was reserved by the startup program is safe, secure, and efficient.

In QNX Neutrino 7.1 or later, you can use the SHMCTL_TYMEM flag for shm_ctl() to directly allocate memory from these pools. The steps are as follows:

  1. Use posix_typed_mem_open() to open the memory pool.
  2. Use shm_open() to create a shared memory object.
  3. Use shm_ctl() to populate the object with memory from the pool.

For example:

// Open the graphics pool
int tymem_fd =
    posix_typed_mem_open( "/graphics", O_RDWR,

// Create a shared memory object
int shm_fd = shm_open(SHM_ANON, O_RDWR, 0600);

// Populate with 1 MB of mostly-contiguous memory
shm_ctl(shm_fd, SHMCTL_ANON | SHMCTL_TYMEM, tymem_fd, 0x100000);

A few things to note: