Memory leaks

A memory leak is a portion of heap memory that was allocated but not freed, with a reference to it that has been lost to the code that allocated the memory. Over time, your program may consume more memory than it really needs. QNX Neutrino tracks the exact memory your program uses and recovers all of this memory, including lost memory, when your program terminates. But if your program has a severe leak, or leaks slowly but runs continuously, it could consume all memory, possibly crashing or causing critical system services to fail.

The Memory Analysis tool can help you detect both apparent and subtle memory leaks. An apparent leak is a chunk of heap memory that's no longer referred to from active memory. A subtle leak is memory that's still referred to but shouldn't be; for example, if a hash or dynamic array holds the references.

The Memory Analysis tooling consists of IDE visualization tools and a runtime library called librcheck.so. The library overrides the allocator and implements an algorithm that can detect memory leaks at runtime. You don't need to recompile your program to enable error detection; the library can be pre-loaded at runtime if you're running your program with Memory Analysis enabled.

You can configure the Memory Analysis tool to perform leak checks at regular intervals and when the process exits, as explained in Enabling leak detection, or when requested from the IDE, as explained in Detecting leaks on demand. You can also use the tool's API to get a dump of leaks, as demonstrated in Tooling API.