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 long long totalPhysical;
60 unsigned long long availPhysical;
61 unsigned long long totalPageFile;
62 unsigned long long availPageFile;
63 unsigned long long totalVirtual;
64 unsigned long long availVirtual;
65};
66
68extern void DumpTotalMemoryStatus();
69
70//------------------------------------------------------------------------------
76#if NEBULA_MEMORY_ADVANCED_DEBUGGING
78extern bool ValidateMemory();
80extern void Checkpoint(const char* msg);
82void EnableMemoryLogging(unsigned int threshold, HeapType heapType = InvalidHeapType);
84void DisableMemoryLogging();
86void ToggleMemoryLogging(unsigned int threshold, HeapType heapType = InvalidHeapType);
88void DumpMemoryLeaks();
89#endif
90
91#if NEBULA_MEMORY_ADVANCED_DEBUGGING
92#define __MEMORY_CHECKPOINT(s) Memory::Checkpoint(##s)
93#else
94#define __MEMORY_CHECKPOINT(s)
95#endif
96
97// FIXME: Memory-Validation disabled for now
98#define __MEMORY_VALIDATE(s)
99} // namespace Memory
100//------------------------------------------------------------------------------
101
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:151
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:140
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:117
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:186
__forceinline void DecommitVirtual(void *ptr, size_t size)
decommit virtual memory
Definition posixmemory.h:128
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 long long availPageFile
Definition win32memory.h:62
unsigned int totalPhysical
Definition osxmemory.h:53
unsigned int availVirtual
Definition osxmemory.h:56
unsigned long long totalPageFile
Definition win32memory.h:61
unsigned int availPhysical
Definition osxmemory.h:54
Central config file for memory setup on the Win32 platform.