check -leaks [-frames n] [-match m]
The -leaks option turns on leak checking. RTC reports the following errors:
aib | Possible memory leak - The only pointer points in the middle of the block |
air | Possible memory leak - The pointer to the block exists only in register |
mel | Memory leak - No pointers to the block |
With leak checking turned on, you get an automatic leak report when the program exits. All leaks including possible leaks are reported at that time. By default, a non-verbose report is generated (controlled by the dbxenv rtc_mel_at_exit). However, you can ask for a leak report at any time.
The -frames n variable displays up to n distinct stack frames when reporting leaks. The -match m variable combines leaks. If the call stack at the time of allocation for two or more leaks matches m frames, these leaks are reported in a single combined leak report. The default value of n is the larger of 8 or the value of m. The maximum value of n is 16. The default value of m is 2.
check -memuse [-frames n] [-match m]
The -memuse option turns on memory use (memuse) checking. Using check -memuse implies using check -leaks. In addition to a leak report at program exit, you also get a blocks in use (biu) report. By default a non-verbose blocks in use report is generated (controlled by the dbxenv rtc_biu_at_exit). At any time during program execution you can see where the memory in your program has been allocated.
The -frames n and -match m variables function as described in the following section.
check -all [-frames n] [-match m]
Equivalent to check -access; check -memuse [-frames n] [-match m]. The value of rtc_biu_at_exit dbxenv variable is not changed with check -all. So, by default, no memory use report is generated at exit.
check [funcs] [files] [loadobjects]
Equivalent to check -all; suppress all; unsuppress all in funcs files loadobjects. You can use this to focus RTC on places of interest.
Other Memory Control Interfaces
sysconf
sysconf(3C) returns the system dependent size of a memory page. For portability, applications should not embed any constants specifying the size of a page. Note that varying page sizes are not unusual, even among implementations of the same instruction set.
mprotect
mprotect(2) assigns the specified protection to all pages in the specified address range. The protection cannot exceed the permissions allowed on the underlying object.
brk and sbrk
A break is the greatest valid data address in the process image that is not in the stack. When a program starts executing, the break value is normally set by execve(2) to the greatest address defined by the program and its data storage.
Use brk(2) to set the break to a greater address, or use sbrk(2) to add an increment of storage to the data segment of a process. You can get the maximum possible size of the data segment by a call to getrlimit(2).
caddr_t brk(caddr_t addr); caddr_t sbrk(intptr_t incr); |
brk identifies the lowest data segment location not used by the caller as addr (rounded up to the next multiple of the system page size).
sbrk, the alternate interface, adds incr bytes to the caller data space and returns a pointer to the start of the new data area.