|
Blender V4.3
|
#include <algorithm>#include <atomic>#include <cassert>#include <iostream>#include <memory>#include <mutex>#include <vector>#include "MEM_guardedalloc.h"#include "mallocn_intern.hh"#include "../../source/blender/blenlib/BLI_strict_flags.h"Go to the source code of this file.
Functions | |
| static std::shared_ptr< Global > & | get_global_ptr () |
| static Global & | get_global () |
| static Local & | get_local_data () |
| static void | update_global_peak () |
| void | memory_usage_init () |
| void | memory_usage_block_alloc (const size_t size) |
| void | memory_usage_block_free (const size_t size) |
| size_t | memory_usage_block_num () |
| size_t | memory_usage_current () |
| size_t | memory_usage_peak () |
| void | memory_usage_peak_reset () |
Variables | |
| static std::atomic< bool > | use_local_counters = true |
| static constexpr int64_t | peak_update_threshold = 1024 * 1024 |
|
static |
Definition at line 119 of file memory_usage.cc.
References get_global_ptr().
Referenced by memory_usage_block_alloc(), memory_usage_block_free(), memory_usage_block_num(), memory_usage_current(), memory_usage_peak(), memory_usage_peak_reset(), and update_global_peak().
|
static |
Definition at line 113 of file memory_usage.cc.
Referenced by get_global().
|
static |
Definition at line 124 of file memory_usage.cc.
Referenced by blender::fn::lazy_function::Executor::execute(), memory_usage_block_alloc(), memory_usage_block_free(), and memory_usage_init().
| void memory_usage_block_alloc | ( | const size_t | size | ) |
Definition at line 188 of file memory_usage.cc.
References get_global(), get_local_data(), LIKELY, peak_update_threshold, update_global_peak(), and use_local_counters.
Referenced by MEM_lockfree_callocN(), MEM_lockfree_mallocN(), and MEM_lockfree_mallocN_aligned().
| void memory_usage_block_free | ( | const size_t | size | ) |
Definition at line 212 of file memory_usage.cc.
References get_global(), get_local_data(), LIKELY, and use_local_counters.
Referenced by MEM_lockfree_freeN().
| size_t memory_usage_block_num | ( | void | ) |
Definition at line 229 of file memory_usage.cc.
References get_global(), and lock.
Referenced by MEM_lockfree_get_memory_blocks_in_use().
| size_t memory_usage_current | ( | void | ) |
Definition at line 242 of file memory_usage.cc.
References get_global(), lock, and mem_in_use.
Referenced by MEM_lockfree_calloc_arrayN(), MEM_lockfree_calloc_arrayN_aligned(), MEM_lockfree_callocN(), MEM_lockfree_get_memory_in_use(), MEM_lockfree_malloc_arrayN(), MEM_lockfree_mallocN(), MEM_lockfree_mallocN_aligned(), MEM_lockfree_printmemlist_stats(), memory_usage_peak_reset(), and update_global_peak().
| void memory_usage_init | ( | void | ) |
Definition at line 182 of file memory_usage.cc.
References get_local_data().
Referenced by MEM_init_memleak_detection().
| size_t memory_usage_peak | ( | void | ) |
Get the approximate peak memory usage since the last call to memory_usage_peak_reset. This is approximate, because the peak usage is not updated after every allocation (see peak_update_threshold).
In the worst case, the peak memory usage is underestimated by peak_update_threshold * #threads. After large allocations (larger than the threshold), the peak usage is always updated so those allocations will always be taken into account.
Definition at line 264 of file memory_usage.cc.
References get_global(), and update_global_peak().
Referenced by MEM_lockfree_get_peak_memory(), and MEM_lockfree_printmemlist_stats().
| void memory_usage_peak_reset | ( | void | ) |
Definition at line 271 of file memory_usage.cc.
References get_global(), and memory_usage_current().
Referenced by MEM_lockfree_reset_peak_memory().
|
static |
Check if the current memory usage is higher than the peak and update it if yes.
Definition at line 166 of file memory_usage.cc.
References get_global(), lock, and memory_usage_current().
Referenced by memory_usage_block_alloc(), and memory_usage_peak().
|
staticconstexpr |
When a thread allocated this amount of memory, the peak memory usage is updated. An alternative would be to update the global peak memory after every allocation, but that would cause much more overhead with little benefit.
Definition at line 111 of file memory_usage.cc.
Referenced by memory_usage_block_alloc().
|
static |
This is true for most of the lifetime of the program. Only when it starts exiting this becomes false indicating that global counters should be used for correctness.
Definition at line 105 of file memory_usage.cc.
Referenced by memory_usage_block_alloc(), and memory_usage_block_free().