gwnavruntime/kernel/HeapPT/HeapPT_MemoryHeap.h Source File

HeapPT_MemoryHeap.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 /**************************************************************************
8 
9 PublicHeader: Kernel
10 Filename : HeapPT_MemoryHeap.h
11 Content : Public memory heap class declaration, PageTable engine.
12 Created : October 1, 2008
13 Authors : Michael Antonov, Maxim Shemanarev
14 
15 **************************************************************************/
16 
17 #ifndef INC_KY_Kernel_HeapPT_MemoryHeap_H
18 #define INC_KY_Kernel_HeapPT_MemoryHeap_H
19 
21 
22 namespace Kaim {
23 
24 namespace HeapPT
25 {
26  class HeapRoot;
27  class AllocEngine;
28  class DebugStorage;
29 }
30 
31 namespace Heap
32 {
33  struct HeapSegment;
34  class MemVisitor;
35  class SegVisitor;
36 }
37 
38 
39 // ***** MemoryHeap
40 //------------------------------------------------------------------------
41 class MemoryHeapPT : public MemoryHeap
42 {
43 private:
44  friend class HeapPT::HeapRoot;
45  friend class HeapMH::RootMH;
46 
47  MemoryHeapPT(); // Explicit creation and destruction is prohibited
48  virtual ~MemoryHeapPT() {}
49 
50 public:
51 
52  // *** Operations with memory arenas
53  //
54  //--------------------------------------------------------------------
55  virtual void CreateArena(UPInt arena, SysAllocPaged* sysAlloc);
56  virtual void DestroyArena(UPInt arena);
57  virtual bool ArenaIsEmpty(UPInt arena);
58 
59  // *** Initialization
60  //
61  // Creates a nested child heap; The heap should be destroyed
62  // by calling release. If child heap creation failed due to
63  // out-of-memory condition, returns 0. If child heap creation
64  // is not supported a pointer to the same parent heap will be returned.
65  //--------------------------------------------------------------------
66  virtual MemoryHeap* CreateHeap(const char* name,
67  const HeapDesc& desc);
68 
69  // *** Service functions
70  //--------------------------------------------------------------------
71 
72  virtual void SetLimitHandler(LimitHandler* handler);
73  virtual void SetLimit(UPInt newLimit);
74  virtual void AddRef();
75  virtual void Release();
76 
77  // *** Allocation API
78  //--------------------------------------------------------------------
79  virtual void* Alloc(UPInt size, const AllocInfo* info = 0);
80  virtual void* Alloc(UPInt size, UPInt align, const AllocInfo* info = 0);
81  virtual void* Realloc(void* oldPtr, UPInt newSize);
82  virtual void Free(void* ptr);
83  virtual void* AllocAutoHeap(const void *thisPtr, UPInt size,
84  const AllocInfo* info = 0);
85 
86  virtual void* AllocAutoHeap(const void *thisPtr, UPInt size, UPInt align,
87  const AllocInfo* info = 0);
88 
89  virtual MemoryHeap* GetAllocHeap(const void *thisPtr);
90 
91  virtual UPInt GetUsableSize(const void* ptr);
92 
93 
94  virtual void* AllocSysDirect(UPInt size);
95  virtual void FreeSysDirect(void* ptr, UPInt size);
96 
97  // *** Statistics
98  //--------------------------------------------------------------------
99  virtual bool GetStats(StatBag* bag);
100  virtual UPInt GetFootprint() const;
101  virtual UPInt GetTotalFootprint() const;
102  virtual UPInt GetUsedSpace() const;
103  virtual UPInt GetTotalUsedSpace() const;
104  virtual void GetRootStats(RootStats* stats);
105  virtual void VisitMem(Heap::MemVisitor* visitor, unsigned flags);
106 
107  virtual void VisitRootSegments(Heap::SegVisitor* visitor);
108  virtual void VisitHeapSegments(Heap::SegVisitor* visitor) const;
109  virtual void SetTracer(HeapTracer* tracer);
110 
111 private:
112  //--------------------------------------------------------------------
113  virtual void destroyItself();
114  virtual void ultimateCheck();
115  virtual void releaseCachedMem();
116  virtual bool dumpMemoryLeaks();
117  virtual void checkIntegrity() const;
118  virtual void getUserDebugStats(RootStats* stats) const;
119 
120  void* allocMem(UPInt size, const AllocInfo* info);
121  void* allocMem(UPInt size, UPInt align, const AllocInfo* info);
122  void* allocMem(const void *thisPtr, UPInt size, const AllocInfo* info);
123  void* allocMem(const void *thisPtr, UPInt size, UPInt align, const AllocInfo* info);
124  void* reallocMem(Heap::HeapSegment* seg, void* oldPtr, UPInt newSize);
125 
126  //--------------------------------------------------------------------
127  HeapPT::AllocEngine* pEngine;
128  HeapPT::DebugStorage* pDebugStorage;
129 };
130 
131 } // Scaleform
132 
133 #endif
Definition: gamekitcrowddispersion.h:20