Memory leak API functions

int purify_all_inuse (void)

Prints a summary message for all heap memory currently allocated.

Return values:

  • 0 indicates that no heap memory is currently allocated.

  • A non-zero value indicates that heap memory is allocated.

int purify_all_leaks (void)

Prints a summary message for all current memory leaks.

Return values:

  • 0 indicates no current leaks.

  • A non-zero value indicates the existence of leaks.

int purify_new_inuse (void)

Prints an incremental message for all new heap memory allocations. This is memory allocated since the last call to the functions purify_new_inuse, purify_all_inuse, or purify_clear_inuse.

Return values:

  • 0 indicates no new heap memory allocations.

  • A non-zero value indicates new heap memory allocations.

int purify_new_leaks (void)

Prints an incremental message for all new leaks (leaks introduced since the last call to the functions purify_new_leaks, purify_all_leaks, or purify_clear_leaks).

Return values:

  • 0 indicates no new leaks.

  • A non-zero value indicates the existence of new leaks.

It is often useful to call this function from the debugger; for example:
 (gdb) break event_loop if (purify_new_leaks())

You can also call it from your program:

event_loop(){
  while(1){
       do stuff
       if (purify_new_leaks()) {
           purify_stop_here_internal();
       }
   }
 }

Note:

  • If you are using this function in a multi-threaded program, run the program with the -search-thread-stacks option set to yes. This option instructs Purify to look at thread stacks, in addition to the main stack, when searching for pointers into the heap.

int purify_clear_inuse (void)

Finds allocated heap memory and notes it as found so that future calls to the function purify_new_inuse do not include it with new heap memory allocaions. This function does not print a message.

int purify_clear_leaks (void)

Finds leaks and marks them cleared so that the function purify_new_leaks does not report them. This function does not print a message. It is useful for ignoring all leaks from a certain portion of code, such as a start-up sequence.