Nebula
Loading...
Searching...
No Matches
win32memory.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12#include "core/config.h"
13#include "core/debug.h"
17#include <new>
18#pragma warning (disable : 4595)
19
20namespace Memory
21{
22extern long volatile TotalAllocCount;
23extern long volatile TotalAllocSize;
24extern long volatile HeapTypeAllocCount[NumHeapTypes];
25extern long volatile HeapTypeAllocSize[NumHeapTypes];
26extern unsigned int volatile MemoryLoggingThreshold;
27extern HeapType volatile MemoryLoggingHeapType;
28
29//------------------------------------------------------------------------------
34extern void* Alloc(HeapType heapType, size_t size, size_t align = 16);
36extern void* Realloc(HeapType heapType, void* ptr, size_t size);
38extern void Free(HeapType heapType, void* ptr);
40extern void* AllocVirtual(size_t size);
42extern void CommitVirtual(void* ptr, size_t size);
44extern void DecommitVirtual(void* ptr, size_t size);
46extern void FreeVirtual(void* ptr, size_t size);
48extern char* DuplicateCString(const char* from);
50extern bool IsOverlapping(const unsigned char* srcPtr, size_t srcSize, const unsigned char* dstPtr, size_t dstSize);
51
52//------------------------------------------------------------------------------
58{
59 unsigned int totalPhysical;
60 unsigned int availPhysical;
61 unsigned int totalVirtual;
62 unsigned int availVirtual;
63};
64
66extern void DumpTotalMemoryStatus();
67
68//------------------------------------------------------------------------------
74#if NEBULA_MEMORY_ADVANCED_DEBUGGING
76extern bool ValidateMemory();
78extern void Checkpoint(const char* msg);
80void EnableMemoryLogging(unsigned int threshold, HeapType heapType = InvalidHeapType);
82void DisableMemoryLogging();
84void ToggleMemoryLogging(unsigned int threshold, HeapType heapType = InvalidHeapType);
86void DumpMemoryLeaks();
87#endif
88
89#if NEBULA_MEMORY_ADVANCED_DEBUGGING
90#define __MEMORY_CHECKPOINT(s) Memory::Checkpoint(##s)
91#else
92#define __MEMORY_CHECKPOINT(s)
93#endif
94
95// FIXME: Memory-Validation disabled for now
96#define __MEMORY_VALIDATE(s)
97} // namespace Memory
98//------------------------------------------------------------------------------
99
Nebula debug macros.
Nebula compiler specific defines and configuration.
Definition arenaallocator.h:31
TotalMemoryStatus GetTotalMemoryStatus()
Get the system's total memory status.
Definition osxmemory.cc:201
__forceinline void FreeVirtual(void *ptr, size_t size)
free virtual memory
Definition posixmemory.h:146
int volatile TotalAllocSize
Definition win32memory.cc:17
int volatile TotalAllocCount
Definition win32memory.cc:16
void * Alloc(HeapType heapType, size_t size, size_t alignment)
Allocate a block of memory from one of the global heaps.
Definition osxmemory.cc:56
__forceinline void CommitVirtual(void *ptr, size_t size)
commit virtual memory
Definition posixmemory.h:135
int volatile HeapTypeAllocCount[NumHeapTypes]
Definition win32memory.cc:18
int volatile HeapTypeAllocSize[NumHeapTypes]
Definition win32memory.cc:19
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition osxmemory.cc:136
void * Realloc(HeapType heapType, void *ptr, size_t size)
Re-Allocate a block of memory from one of the global heaps.
Definition osxmemory.cc:99
HeapType volatile MemoryLoggingHeapType
Definition win32memory.cc:22
__forceinline void * AllocVirtual(size_t size)
allocate a range of virtual memory space
Definition posixmemory.h:112
char * DuplicateCString(const char *from)
Duplicate a 0-terminated string, this method should no longer be used!
Definition osxmemory.cc:166
unsigned int volatile MemoryLoggingThreshold
Definition win32memory.cc:21
HeapType
Heap types are defined here.
Definition osxmemoryconfig.h:25
@ NumHeapTypes
Definition osxmemoryconfig.h:36
@ InvalidHeapType
Definition osxmemoryconfig.h:37
bool IsOverlapping(const unsigned char *srcPtr, size_t srcSize, const unsigned char *dstPtr, size_t dstSize)
Test if 2 areas of memory areas are overlapping.
Definition osxmemory.cc:180
void DumpTotalMemoryStatus()
Dump detail memory status information.
Definition win32memory.cc:183
__forceinline void DecommitVirtual(void *ptr, size_t size)
decommit virtual memory
Definition posixmemory.h:123
Get the system's total current memory, this does not only include Nebula's memory allocations but the...
Definition osxmemory.h:52
unsigned int totalVirtual
Definition osxmemory.h:55
unsigned int totalPhysical
Definition osxmemory.h:53
unsigned int availVirtual
Definition osxmemory.h:56
unsigned int availPhysical
Definition osxmemory.h:54
Central config file for memory setup on the Win32 platform.