forked from bartvdbraak/blender
Cycles: Fix static initialization order fiasco
Initialization order of global stats and node types was not strictly defined and it was possible to have node types initialized first and stats after that. This will zero out memory which was allocated from the statistics causing assert failure when de-initializing node types.
This commit is contained in:
parent
963aa7e270
commit
cde18cf3b3
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
static Stats global_stats;
|
static Stats global_stats(Stats::static_init);
|
||||||
|
|
||||||
/* Internal API. */
|
/* Internal API. */
|
||||||
|
|
||||||
|
@ -23,7 +23,10 @@ CCL_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
class Stats {
|
class Stats {
|
||||||
public:
|
public:
|
||||||
|
enum static_init_t { static_init = 0 };
|
||||||
|
|
||||||
Stats() : mem_used(0), mem_peak(0) {}
|
Stats() : mem_used(0), mem_peak(0) {}
|
||||||
|
explicit Stats(static_init_t) {}
|
||||||
|
|
||||||
void mem_alloc(size_t size) {
|
void mem_alloc(size_t size) {
|
||||||
atomic_add_z(&mem_used, size);
|
atomic_add_z(&mem_used, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user