Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
osxheap.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
12
#include "
core/types.h
"
13
14
//------------------------------------------------------------------------------
15
namespace
OSX
16
{
17
class
OSXHeap
18
{
19
public
:
21
static
void
Setup
();
23
OSXHeap
(
const
char
*
name
,
size_t
initialSize=64 * 1024);
25
~OSXHeap
();
27
const
char
*
GetName
()
const
;
29
void
*
Alloc
(
size_t
size,
size_t
alignment=16);
31
void
*
Realloc
(
void
* ptr,
size_t
newSize);
33
void
Free
(
void
* ptr);
34
35
#if NEBULA_MEMORY_STATS
37
struct
Stats
38
{
39
const
char
*
name
;
40
int
allocCount;
41
int
allocSize;
42
};
44
static
Util::Array<Stats>
GetAllHeapStats();
46
static
bool
ValidateAllHeaps();
48
bool
ValidateHeap()
const
;
50
void
DumpLeaks();
52
static
void
DumpLeaksAllHeaps();
54
int
GetAllocCount()
const
;
56
int
GetAllocSize()
const
;
57
#endif
58
59
private
:
61
OSXHeap
();
62
63
const
char
*
name
;
64
malloc_zone_t*
heapZone
;
65
66
#if NEBULA_MEMORY_STATS
67
int
volatile
allocCount;
68
int
volatile
allocSize;
69
static
Threading::CriticalSection* criticalSection;
70
static
Util::List<OSXHeap*>
* list;
71
Util::List<OSXHeap*>::Iterator
listIterator;
72
#endif
73
};
74
75
//------------------------------------------------------------------------------
78
inline
const
char
*
79
OSXHeap::GetName
()
const
80
{
81
n_assert
(0 != this->
name
);
82
return
this->
name
;
83
}
84
85
}
// namespace OSX
OSX::OSXHeap::OSXHeap
OSXHeap()
default constructor not allowed
OSX::OSXHeap::Free
void Free(void *ptr)
free a block of memory
Definition
osxheap.cc:121
OSX::OSXHeap::~OSXHeap
~OSXHeap()
destructor
Definition
osxheap.cc:56
OSX::OSXHeap::Realloc
void * Realloc(void *ptr, size_t newSize)
re-allocate a block of memory
Definition
osxheap.cc:100
OSX::OSXHeap::heapZone
malloc_zone_t * heapZone
Definition
osxheap.h:64
OSX::OSXHeap::Setup
static void Setup()
static setup method (called by Core::SysFunc::Setup)
Definition
osxheap.cc:24
OSX::OSXHeap::OSXHeap
OSXHeap(const char *name, size_t initialSize=64 *1024)
constructor (name must be a static string!)
Definition
osxheap.cc:37
OSX::OSXHeap::name
const char * name
Definition
osxheap.h:63
OSX::OSXHeap::Alloc
void * Alloc(size_t size, size_t alignment=16)
allocate a block of memory from the heap
Definition
osxheap.cc:81
OSX::OSXHeap::GetName
const char * GetName() const
get heap name
Definition
osxheap.h:79
Util::Array
Nebula's dynamic array class.
Definition
array.h:61
Util::List::Iterator
the list iterator
Definition
list.h:76
Util::List
Implements a doubly linked list.
Definition
list.h:20
n_assert
#define n_assert(exp)
Definition
debug.h:50
OSX
Definition
osxsysfunc.h:21
types.h
code
foundation
memory
osx
osxheap.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.