Previous Section Next Section

SM_HEAP_CHECK

Memory-leak detection (V8.12 and above) port with confENVDEF

The libsm library in the sendmail source distribution offers a way to provide memory leak detection and error checking that overlays the usual malloc(3), realloc(3), and free(3) C-language library routines. To disable extra checking, define SM_HEAP_CHECK as zero:

APPENDDEF(`confENVDEF', `-DSM_HEAP_CHECK=0')

If you choose to enable extra checking, it will not be turned on by default. Instead you will need to turn it on and off with special debugging command-line switches (we cover this soon). To enable extra checking, define SM_HEAP_CHECK as 1:

APPENDDEF(`confENVDEF', `-DSM_HEAP_CHECK=1')

Once extra checking has been included in your sendmail code, you can turn it on and off with debugging command-line switches. The category is sm_check_heap, and there are four meaningful levels:

# /usr/sbin/sendmail -dsm_check_heap.level ... 

The four meaningful values for level are shown in Table 3-12.

Table 3-12. Debugging levels for memory validity checking

Level

Description

1

This level causes a table of all currently allocated blocks to be maintained. The table is used by the sendmail hooks sm_realloc( ) and sm_free( ) to perform validity checks on their first arguments.

2

With this level, a report will be printed just before sendmail exits. That report contains a single line listing the total storage allocation used in bytes.

3

With this level, a report will be printed just before sendmail exits. That report, in addition to the report given previously, will also list all leaked blocks of memory.

4

With this level, a report will be printed just before sendmail exits. That report, in addition to the reports given previously, will also list all allocated memory blocks.

The -dsm_check_heap command-line switch is most useful when porting sendmail to a new machine. It can also be valuable when adding new functions to sendmail or to its companion programs.

To see if this compile-time macro is defined with your sendmail binary, use the -d0.12 debugging command-line switch.

Previous Section Next Section