Blender  V3.3
Functions | Variables
leak_detector.cc File Reference
#include <cstdio>
#include <cstdlib>
#include "MEM_guardedalloc.h"
#include "mallocn_intern.h"

Go to the source code of this file.

Functions

void MEM_init_memleak_detection ()
 
void MEM_use_memleak_detection (bool enabled)
 
void MEM_enable_fail_on_memleak ()
 

Variables

bool leak_detector_has_run = false
 
char free_after_leak_detection_message []
 

Function Documentation

◆ MEM_enable_fail_on_memleak()

void MEM_enable_fail_on_memleak ( void  )

When this has been called and memory leaks have been detected, the process will have an exit code that indicates failure. This can be used for when checking for memory leaks with automated tests.

Definition at line 73 of file leak_detector.cc.

Referenced by arg_handle_debug_exit_on_error().

◆ MEM_init_memleak_detection()

void MEM_init_memleak_detection ( void  )

This should be called as early as possible in the program. When it has been called, information about memory leaks will be printed on exit.

This variable is constructed when this function is first called. This should happen as soon as possible when the program starts.

It is destructed when the program exits. During destruction, it will print information about leaked memory blocks. Static variables are destructed in reversed order of their construction. Therefore, all static variables that own memory have to be constructed after this function has been called.

Definition at line 54 of file leak_detector.cc.

Referenced by main().

◆ MEM_use_memleak_detection()

void MEM_use_memleak_detection ( bool  enabled)

Use this if we want to call #exit during argument parsing for example, without having to free all data.

Definition at line 68 of file leak_detector.cc.

References enabled.

Referenced by main().

Variable Documentation

◆ free_after_leak_detection_message

char free_after_leak_detection_message[]
Initial value:
=
"Freeing memory after the leak detector has run. This can happen when using "
"static variables in C++ that are defined outside of functions. To fix this "
"error, use the 'construct on first use' idiom."

Definition at line 14 of file leak_detector.cc.

Referenced by MEM_guarded_freeN(), and MEM_lockfree_freeN().

◆ leak_detector_has_run

bool leak_detector_has_run = false

Definition at line 13 of file leak_detector.cc.

Referenced by MEM_guarded_freeN(), and MEM_lockfree_freeN().