absl::IgnoreLeak

Instruct the leak sanitizer to ignore leak warnings on the object referenced by the passed pointer, as well as all heap objects transitively referenced by it. The passed object pointer can point to either the beginning of the object or anywhere within it.

Synopsis

Declared in <absl/debugging/leak_check.h>

template<typename T>
T*
IgnoreLeak(T* ptr);

Description

Example:

static T* obj = IgnoreLeak(new T(...));

If the passed ptr does not point to an actively allocated object at the time IgnoreLeak() is called, the call is a no-op; if it is actively allocated, leak sanitizer will assume this object is referenced even if there is no actual reference in user memory.

Return Value

The same pointer that was passed in.

Parameters

NameDescription
ptrPointer to the object whose leaks should be ignored.