blob: 1c89d285e8ba0ac3c7675822ff5595166e52e424 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#ifndef ALLOCATORLABELS_H
#define ALLOCATORLABELS_H
#include "Runtime/Modules/ExportModules.h"
#define ENABLE_MEM_PROFILER (ENABLE_MEMORY_MANAGER && ENABLE_PROFILER)
#if ENABLE_MEM_PROFILER
#define IF_MEMORY_PROFILER_ENABLED(x) x
#else
#define IF_MEMORY_PROFILER_ENABLED(x)
#endif
// Must be in Sync with ENUM WiiMemory in PlayerSettings.txt
enum MemLabelIdentifier
{
#define DO_LABEL(Name) kMem##Name##Id ,
#include "AllocatorLabelNames.h"
#undef DO_LABEL
kMemLabelCount
};
struct AllocationRootReference;
struct ProfilerAllocationHeader;
struct EXPORT_COREMODULE MemLabelId {
MemLabelId() { IF_MEMORY_PROFILER_ENABLED( rootReference = NULL ); }
explicit MemLabelId ( MemLabelIdentifier id, ProfilerAllocationHeader* root ) : label(id) { IF_MEMORY_PROFILER_ENABLED( rootReference = NULL; SetRootHeader(root) ); }
void Initialize ( MemLabelIdentifier id ) { label = id; IF_MEMORY_PROFILER_ENABLED( rootReference = NULL ); }
MemLabelIdentifier label;
#if ENABLE_MEM_PROFILER
MemLabelId ( const MemLabelId& other );
~MemLabelId () { if(rootReference) ReleaseReference(); }
const MemLabelId& operator= (const MemLabelId& other);
void ReleaseReference();
ProfilerAllocationHeader* GetRootHeader () const;
void SetRootHeader ( ProfilerAllocationHeader* rootHeader );
bool UseAutoRoot () const { return rootReference == NULL; };
private:
// root reference = NULL: use stack to get root
AllocationRootReference* rootReference;
#else
ProfilerAllocationHeader* GetRootHeader () const {return NULL;}
void SetRootHeader ( ProfilerAllocationHeader* rootHeader ) {}
#endif
};
#if ENABLE_MEM_PROFILER
typedef const MemLabelId& MemLabelRef;
#else
typedef MemLabelId MemLabelRef;
#endif
#define DO_LABEL_STRUCT(Name) struct EXPORT_COREMODULE Name##Struct : public MemLabelId { }; extern EXPORT_COREMODULE Name##Struct Name;
#define DO_LABEL(Name) DO_LABEL_STRUCT(kMem##Name)
#include "AllocatorLabelNames.h"
#undef DO_LABEL
#undef DO_LABEL_STRUCT
void InitializeMemoryLabels();
//#if UNITY_ENABLE_ACCOUNTING_ALLOCATORS
extern const char* const MemLabelName[];
//#endif
#endif
|